Skip to content

Commit d8f867f

Browse files
author
arutyunyan
committed
release 7.0.1
1 parent d4a9b0e commit d8f867f

File tree

9 files changed

+67
-1
lines changed

9 files changed

+67
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## v7.0.1 - June 02, 2021
4+
5+
- Add smart joins
6+
7+
---
8+
39
## v7.0.0 - May 28, 2021
410

511
- Add syntax sugar

README.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,35 @@ The minimum requirement - PHP 5.6.
99
### Examples
1010
More examples in the ```tests``` directory
1111

12-
## Tests
12+
### Tests
1313
`./vendor/bin/phpunit tests`
1414

15+
### Example with Database
16+
```php
17+
18+
use app\models\User;
19+
use suql\db\Container;
20+
21+
require 'vendor/autoload.php';
22+
23+
Container::create(require __DIR__ . '/app/config/db.php');
24+
25+
$users = User::all()->select(['login' => 'uname']);
26+
$groups = $users->getGroup()->fetchAll();
27+
28+
print_r($groups);
29+
```
30+
31+
In the ```ActiveRecord``` class
32+
```php
33+
...
34+
public function getDb()
35+
{
36+
return Container::get('db');
37+
}
38+
...
39+
```
40+
1541
## Conclusion
1642
SuQL is all about modifiers. They already replace standart SQL clauses such as `WHERE`, `GROUP`, `JOIN`, `ORDER` and SQL functions etc.
1743
More than that, you can develop your own modifiers.

app/models/User.php

+5
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ public function table()
1010
{
1111
return 'users';
1212
}
13+
14+
public function fields()
15+
{
16+
return [];
17+
}
1318
}

src/syntax/SuQL.php

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ abstract class SuQL extends Obj implements QueryObject
3131
* @var string текущая таблица в цепочке вызовов
3232
*/
3333
private $currentTable = null;
34+
/**
35+
* Модель должна содержать перечень полей
36+
*/
37+
abstract public function fields();
3438
/**
3539
* Получает экземпляр модели
3640
* @return self

tests/suql/models/ActiveGroups.php

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public function table()
1717
return 'users';
1818
}
1919

20+
public function fields()
21+
{
22+
return [];
23+
}
24+
2025
public function view()
2126
{
2227
return

tests/suql/models/LastRegistration.php

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public function table()
1717
return 'users';
1818
}
1919

20+
public function fields()
21+
{
22+
return [];
23+
}
24+
2025
public function view()
2126
{
2227
return $this->select([

tests/suql/models/NoName.php

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public function table()
1616
return ActiveGroups::all();
1717
}
1818

19+
public function fields()
20+
{
21+
return [];
22+
}
23+
1924
public function view()
2025
{
2126
return $this->select([

tests/suql/models/RawQuery.php

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public function table()
1616
return null;
1717
}
1818

19+
public function fields()
20+
{
21+
return [];
22+
}
23+
1924
public function view()
2025
{
2126
return $this->select([

tests/suql/models/User.php

+5
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ public function table()
1010
{
1111
return 'users';
1212
}
13+
14+
public function fields()
15+
{
16+
return [];
17+
}
1318
}

0 commit comments

Comments
 (0)