1 | <?php |
||
10 | trait SelectionTrait |
||
11 | { |
||
12 | protected $where = []; |
||
13 | protected $marks = []; |
||
14 | protected $limit; |
||
15 | protected $offset; |
||
16 | |||
17 | /** |
||
18 | * Adds new marks to the query. |
||
19 | * |
||
20 | * @param array $marks |
||
21 | * |
||
22 | * @return self |
||
23 | */ |
||
24 | public function marks(array $marks) |
||
30 | |||
31 | /** |
||
32 | * Adds a WHERE clause. |
||
33 | * |
||
34 | * @param string $where |
||
35 | * @param null|array $marks |
||
36 | * |
||
37 | * @return self |
||
38 | */ |
||
39 | public function where($where, $marks = null) |
||
49 | |||
50 | /** |
||
51 | * Adds a OR WHERE clause. |
||
52 | * |
||
53 | * @param string $where |
||
54 | * @param null|array $marks |
||
55 | * |
||
56 | * @return self |
||
57 | */ |
||
58 | public function orWhere($where, $marks = null) |
||
72 | |||
73 | /** |
||
74 | * Adds a WHERE field = :value clause. |
||
75 | * |
||
76 | * @param string $field |
||
77 | * @param null|int|array $value |
||
78 | * |
||
79 | * @return self |
||
80 | */ |
||
81 | public function by($field, $value) |
||
97 | |||
98 | /** |
||
99 | * Adds a WHERE id = :id clause. |
||
100 | * |
||
101 | * @param null|int|array $id |
||
102 | * |
||
103 | * @return self |
||
104 | */ |
||
105 | public function byId($id) |
||
113 | |||
114 | /** |
||
115 | * Adds a LIMIT clause. |
||
116 | * |
||
117 | * @param int $limit |
||
118 | * |
||
119 | * @return self |
||
120 | */ |
||
121 | public function limit($limit) |
||
127 | |||
128 | /** |
||
129 | * Adds an offset to the LIMIT clause. |
||
130 | * |
||
131 | * @param int $offset |
||
132 | * |
||
133 | * @return self |
||
134 | */ |
||
135 | public function offset($offset) |
||
141 | |||
142 | /** |
||
143 | * Generate WHERE clause. |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | protected function whereToString() |
||
159 | |||
160 | /** |
||
161 | * Generate LIMIT clause. |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | protected function limitToString() |
||
179 | } |
||
180 |