1 | <?php |
||
21 | trait EntityQueryTrait |
||
22 | { |
||
23 | use QueryTrait; |
||
24 | |||
25 | public $noInitModel; |
||
26 | |||
27 | /** |
||
28 | * Build model without any initializations. |
||
29 | */ |
||
30 | 50 | 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 | 5 | public function guid($guid, $like = false) |
|
45 | { |
||
46 | 5 | $model = $this->noInitModel; |
|
47 | 5 | return $this->likeCondition($guid, $model->guidAttribute, $like); |
|
48 | } |
||
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 | 12 | public function id($id, $like = false) |
|
61 | |||
62 | /** |
||
63 | * Specify create time range. |
||
64 | * @param string $start |
||
65 | * @param string $end |
||
66 | * @return $this |
||
67 | */ |
||
68 | 1 | public function createdAt($start = null, $end = null) |
|
76 | |||
77 | /** |
||
78 | * Specify update time range. |
||
79 | * @param string $start |
||
80 | * @param string $end |
||
81 | * @return $this |
||
82 | */ |
||
83 | 1 | public function updatedAt($start = null, $end = null) |
|
91 | |||
92 | public static $pageAll = 'all'; |
||
93 | public static $defaultPageSize = 10; |
||
94 | |||
95 | /** |
||
96 | * Specify page condition. |
||
97 | * @param string|int $currentPage It will return all models if it is 'all', |
||
98 | * or it will be regarded as current page number if it is integer begun with 0. |
||
99 | * @param int $pageSize The sum of models. |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function page($currentPage = 0, $pageSize = 10) |
||
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: