1 | <?php |
||
42 | class Query extends Component implements QueryInterface |
||
43 | { |
||
44 | use QueryTrait; |
||
45 | |||
46 | const SEARCH_SCOPE_SUB = 'ldap_search'; |
||
47 | const SEARCH_SCOPE_ONE = 'ldap_list'; |
||
48 | const SEARCH_SCOPE_BASE = 'ldap_read'; |
||
49 | |||
50 | /** |
||
51 | * @var string the scope of search |
||
52 | * The search scope: |
||
53 | * Query::SEARCH_SCOPE_SUB searches the complete subtree including the $baseDn node. This is the default value. |
||
54 | * Query::SEARCH_SCOPE_ONE restricts search to one level below $baseDn. |
||
55 | * Query::SEARCH_SCOPE_BASE restricts search to the $baseDn itself; this can be used to efficiently retrieve a single entry by its DN. |
||
56 | */ |
||
57 | public $scope = self::SEARCH_SCOPE_SUB; |
||
58 | |||
59 | /** |
||
60 | * @var array the columns being selected. For example, `['id', 'name']`. |
||
61 | * This is used to construct the SEARCH function in a LDAP statement. If not set, it means selecting all columns. |
||
62 | * @see select() |
||
63 | */ |
||
64 | public $select; |
||
65 | |||
66 | /** |
||
67 | * @var string The search filter. Format is described in the LDAP documentation. |
||
68 | * @see http://www.faqs.org/rfcs/rfc4515.html |
||
69 | */ |
||
70 | public $filter; |
||
71 | |||
72 | /** |
||
73 | * Creates a LDAP command that can be used to execute this query. |
||
74 | * @param Connection $db the database connection. |
||
75 | * If this parameter is not given, the `db` application component will be used. |
||
76 | * @return DataReader |
||
77 | */ |
||
78 | public function execute($db = null) |
||
102 | |||
103 | /** |
||
104 | * Prepares for building SQL. |
||
105 | * This method is called by [[QueryBuilder]] when it starts to build SQL from a query object. |
||
106 | * You may override this method to do some final preparation work when converting a query into a SQL statement. |
||
107 | * @param QueryBuilder $builder |
||
108 | * @return $this a prepared query instance which will be used by [[QueryBuilder]] to build the SQL |
||
109 | */ |
||
110 | public function prepare($builder) |
||
114 | |||
115 | /** |
||
116 | * Executes the query and returns all results as an array. |
||
117 | * @param Connection $db the database connection. |
||
118 | * If this parameter is not given, the `db` application component will be used. |
||
119 | * @return array the query results. If the query results in nothing, an empty array will be returned. |
||
120 | */ |
||
121 | public function all($db = null) |
||
127 | |||
128 | /** |
||
129 | * Converts the raw query results into the format as specified by this query. |
||
130 | * This method is internally used to convert the data fetched from database |
||
131 | * into the format as required by this query. |
||
132 | * @param array $rows the raw query result from database |
||
133 | * @return array the converted query result |
||
134 | */ |
||
135 | public function populate($rows) |
||
151 | |||
152 | /** |
||
153 | * Executes the query and returns a single row of result. |
||
154 | * @param Connection $db the database connection. |
||
155 | * If this parameter is not given, the `db` application component will be used. |
||
156 | * @return array|boolean the first row (in terms of an array) of the query result. False is returned if the query |
||
157 | * results in nothing. |
||
158 | */ |
||
159 | public function one($db = null) |
||
165 | |||
166 | /** |
||
167 | * Returns the number of entries in a search. |
||
168 | * @param Connection $db the database connection |
||
169 | * If this parameter is not given (or null), the `db` application component will be used. |
||
170 | * @return integer number of entries. |
||
171 | */ |
||
172 | public function count($q = '*', $db = NULL) |
||
177 | |||
178 | |||
179 | /** |
||
180 | * Returns a value indicating whether the query result contains any row of data. |
||
181 | * @param Connection $db the database connection. |
||
182 | * If this parameter is not given, the `db` application component will be used. |
||
183 | * @return boolean whether the query result contains any row of entries. |
||
184 | */ |
||
185 | public function exists($db = null) |
||
190 | |||
191 | /** |
||
192 | * Sets the SELECT part of the query. |
||
193 | * @param string|array $columns the columns to be selected. |
||
194 | * Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']). |
||
195 | * |
||
196 | * ```php |
||
197 | * $query->addSelect(['cn, mail'])->one(); |
||
198 | * ``` |
||
199 | * |
||
200 | * @return $this the query object itself |
||
201 | */ |
||
202 | public function select($columns) |
||
210 | |||
211 | /** |
||
212 | * Add more columns to the select part of the query. |
||
213 | * |
||
214 | * ```php |
||
215 | * $query->addSelect(['cn, mail'])->one(); |
||
216 | * ``` |
||
217 | * |
||
218 | * @param string|array|Expression $columns the columns to add to the select. See [[select()]] for more |
||
219 | * details about the format of this parameter. |
||
220 | * @return $this the query object itself |
||
221 | * @see select() |
||
222 | */ |
||
223 | public function addSelect($columns) |
||
235 | |||
236 | /** |
||
237 | * Adds a filtering condition for a specific column and allow the user to choose a filter operator. |
||
238 | * |
||
239 | * It adds an additional WHERE condition for the given field and determines the comparison operator |
||
240 | * based on the first few characters of the given value. |
||
241 | * The condition is added in the same way as in [[andFilterWhere]] so [[isEmpty()|empty values]] are ignored. |
||
242 | * The new condition and the existing one will be joined using the 'AND' operator. |
||
243 | * |
||
244 | * The comparison operator is intelligently determined based on the first few characters in the given value. |
||
245 | * In particular, it recognizes the following operators if they appear as the leading characters in the given value: |
||
246 | * |
||
247 | * - `<`: the column must be less than the given value. |
||
248 | * - `>`: the column must be greater than the given value. |
||
249 | * - `<=`: the column must be less than or equal to the given value. |
||
250 | * - `>=`: the column must be greater than or equal to the given value. |
||
251 | * - `~=`: the column must approximate the given value. |
||
252 | * - `=`: the column must be equal to the given value. |
||
253 | * - If none of the above operators is detected, the `$defaultOperator` will be used. |
||
254 | * |
||
255 | * @param string $name the column name. |
||
256 | * @param string $value the column value optionally prepended with the comparison operator. |
||
257 | * @param string $defaultOperator The operator to use, when no operator is given in `$value`. |
||
258 | * Defaults to `=`, performing an exact match. |
||
259 | * @return $this The query object itself |
||
260 | */ |
||
261 | public function andFilterCompare($name, $value, $defaultOperator = '=') |
||
271 | |||
272 | /** |
||
273 | * Creates a new Query object and copies its property values from an existing one. |
||
274 | * The properties being copies are the ones to be used by query builders. |
||
275 | * @param Query $from the source query object |
||
276 | * @return Query the new Query object |
||
277 | */ |
||
278 | public static function create(Query $from) |
||
289 | } |
||
290 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.