1 | <?php |
||
21 | trait EntityQueryTrait |
||
22 | { |
||
23 | use QueryTrait; |
||
24 | |||
25 | public $noInitModel; |
||
26 | |||
27 | /** |
||
28 | * Build model without any initializations. |
||
29 | */ |
||
30 | 117 | public function buildNoInitModel() |
|
37 | |||
38 | /** |
||
39 | * Specify guid attribute. |
||
40 | * @param string|array $guid |
||
41 | * @param false|string $like false, 'like', 'or like', 'not like', 'or not like'. |
||
42 | * @return $this |
||
43 | */ |
||
44 | 8 | public function guid($guid, $like = false) |
|
49 | |||
50 | /** |
||
51 | * Specify id attribute. |
||
52 | * @param string|integer|array $id |
||
53 | * @param false|string $like false, 'like', 'or like', 'not like', 'or not like'. |
||
54 | * @return $this |
||
55 | */ |
||
56 | 1 | public function id($id, $like = false) |
|
57 | { |
||
58 | 1 | $model = $this->noInitModel; |
|
59 | 1 | return $this->likeCondition($id, $model->idAttribute, $like); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Specify create time range. |
||
64 | * @param string $start |
||
65 | * @param string $end |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function createdAt($start = null, $end = null) |
||
77 | |||
78 | /** |
||
79 | * Specify update time range. |
||
80 | * @param string $start |
||
81 | * @param string $end |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function updatedAt($start = null, $end = null) |
||
93 | public static $pageAll = 'all'; |
||
94 | public static $defaultPageSize = 10; |
||
95 | |||
96 | /** |
||
97 | * Specify page condition. |
||
98 | * @param string|int $pageSize It will return all models if it is 'all', |
||
99 | * or it will be regarded as sum of models. |
||
100 | * @param int $currentPage The current page number if it is integer begun with 0. |
||
101 | * @return $this |
||
102 | */ |
||
103 | 1 | public function page($pageSize = 10, $currentPage = 0) |
|
119 | } |
||
120 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: