1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace TheCodingMachine\TDBM\Dao; |
||
6 | |||
7 | use TheCodingMachine\TDBM\Test\Dao\Bean\CountryBean; |
||
0 ignored issues
–
show
|
|||
8 | use TheCodingMachine\TDBM\Test\Dao\Bean\UserBean; |
||
0 ignored issues
–
show
The type
TheCodingMachine\TDBM\Test\Dao\Bean\UserBean was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
9 | use TheCodingMachine\TDBM\Test\Dao\Generated\UserBaseDao; |
||
0 ignored issues
–
show
The type
TheCodingMachine\TDBM\Te...o\Generated\UserBaseDao was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
10 | use TheCodingMachine\TDBM\Test\ResultIterator\UserResultIterator; |
||
0 ignored issues
–
show
The type
TheCodingMachine\TDBM\Te...ator\UserResultIterator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
11 | use TheCodingMachine\TDBM\UncheckedOrderBy; |
||
12 | |||
13 | /** |
||
14 | * The UserDao class will maintain the persistence of UserBean class into the users table. |
||
15 | */ |
||
16 | class TestUserDao extends UserBaseDao |
||
17 | { |
||
18 | /** |
||
19 | * Returns the list of users by alphabetical order. |
||
20 | */ |
||
21 | public function getUsersByAlphabeticalOrder(): UserResultIterator |
||
22 | { |
||
23 | // The third parameter will be used in the "ORDER BY" clause of the SQL query. |
||
24 | return $this->find(null, [], 'login ASC'); |
||
25 | } |
||
26 | /** |
||
27 | * Returns the list of users by alphabetical order. |
||
28 | */ |
||
29 | public function getUsersFromSqlByAlphabeticalOrder(): UserResultIterator |
||
30 | { |
||
31 | // The third parameter will be used in the "ORDER BY" clause of the SQL query. |
||
32 | return $this->findFromSql('users', null, [], 'users.login ASC'); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Returns the list of users by alphabetical order. |
||
37 | */ |
||
38 | public function getUsersByCountryOrder(): UserResultIterator |
||
39 | { |
||
40 | // The third parameter will be used in the "ORDER BY" clause of the SQL query. |
||
41 | return $this->find(null, [], 'country.label ASC', ['country']); |
||
42 | } |
||
43 | /** |
||
44 | * Returns the list of users by alphabetical order. |
||
45 | */ |
||
46 | public function getUsersFromSqlByCountryOrder(): UserResultIterator |
||
47 | { |
||
48 | // The third parameter will be used in the "ORDER BY" clause of the SQL query. |
||
49 | return $this->findFromSql('users JOIN country ON country.id = users.country_id', null, [], 'country.label ASC'); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Returns the list of users whose login starts with $login. |
||
54 | * |
||
55 | * @param string $login |
||
56 | * @param string $mode |
||
57 | */ |
||
58 | public function getUsersByLoginStartingWith($login = null, $mode = null): UserResultIterator |
||
59 | { |
||
60 | return $this->find('login LIKE :login', ['login' => $login.'%'], null, [], $mode); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Returns the user whose login is $login. |
||
65 | * |
||
66 | * @param string $login |
||
67 | * |
||
68 | * @return UserBean |
||
69 | */ |
||
70 | public function getUserByLogin($login) |
||
71 | { |
||
72 | return $this->findOne('login = :login', ['login' => $login]); |
||
73 | } |
||
74 | |||
75 | public function getUsersByManagerId($managerId) |
||
76 | { |
||
77 | return $this->find('contact.manager_id = :id!', ['id' => $managerId]); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Triggers an error because table "contacts" does not exist. |
||
82 | */ |
||
83 | public function getUsersWrongTableName(): UserResultIterator |
||
84 | { |
||
85 | return $this->find('contacts.manager_id = 1'); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Returns a list of users, sorted by a table on an external column. |
||
90 | */ |
||
91 | public function getUsersByCountryName(): UserResultIterator |
||
92 | { |
||
93 | return $this->find(null, [], 'country.label DESC'); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * A test to sort by function. |
||
98 | */ |
||
99 | public function getUsersByReversedCountryName(): UserResultIterator |
||
100 | { |
||
101 | return $this->find(null, [], new UncheckedOrderBy('REVERSE(country.label) ASC')); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * A test to check exceptions when providing expressions in ORDER BY clause. |
||
106 | * |
||
107 | * @return \TheCodingMachine\TDBM\ResultIterator|UserBean[] |
||
108 | */ |
||
109 | public function getUsersByInvalidOrderBy() |
||
110 | { |
||
111 | return $this->find(null, [], 'REVERSE(country.label) ASC'); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @param CountryBean $country |
||
116 | * @param string[] $names |
||
117 | * @return \TheCodingMachine\TDBM\ResultIterator|UserBean[] |
||
118 | */ |
||
119 | public function getUsersByComplexFilterBag(CountryBean $country, array $names) |
||
120 | { |
||
121 | $filterBag = [ |
||
122 | 'person.name' => $names |
||
123 | ]; |
||
124 | $filterBag[] = $country; |
||
125 | return $this->find($filterBag); |
||
126 | } |
||
127 | } |
||
128 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths