1 | <?php |
||
20 | trait OrderByTrait |
||
21 | { |
||
22 | /** |
||
23 | * @var bool Whether results should be returned in the order specified by [[domain]]. |
||
24 | */ |
||
25 | public $fixedOrder = false; |
||
26 | |||
27 | /** |
||
28 | * Sets the ORDER BY part of the query. |
||
29 | * @param string|array|Expression $columns the columns (and the directions) to be ordered by. |
||
30 | * Columns can be specified in either a string (e.g. `"id ASC, name DESC"`) or an array |
||
31 | * (e.g. `['id' => SORT_ASC, 'name' => SORT_DESC]`). |
||
32 | * |
||
33 | * The method will automatically quote the column names unless a column contains some parenthesis |
||
34 | * (which means the column contains a DB expression). |
||
35 | * |
||
36 | * Note that if your order-by is an expression containing commas, you should always use an array |
||
37 | * to represent the order-by information. Otherwise, the method will not be able to correctly determine |
||
38 | * the order-by columns. |
||
39 | * |
||
40 | * Since version 2.0.7, an [[Expression]] object can be passed to specify the ORDER BY part explicitly in plain SQL. |
||
41 | * @return $this the query object itself |
||
42 | * @see addOrderBy() |
||
43 | */ |
||
44 | abstract public function orderBy($columns); |
||
45 | |||
46 | /** |
||
47 | * Applies the 'fixedOrder' and 'orderBy' params to the query being prepared. |
||
48 | * |
||
49 | * @param Connection|null $db The database connection used to generate the SQL statement. |
||
50 | * If this parameter is not given, the `db` application component will be used. |
||
51 | */ |
||
52 | protected function applyOrderByParams(Connection $db) |
||
65 | |||
66 | /** |
||
67 | * @noinspection PhpUnusedParameterInspection |
||
68 | * |
||
69 | * @param Connection $db |
||
70 | */ |
||
71 | protected function applyEmptyOrderByParams(Connection $db) |
||
75 | } |
||
76 |