@@ 227-248 (lines=22) @@ | ||
224 | * |
|
225 | * @return \samsoncms\api\Entity[] Collection of found entities |
|
226 | */ |
|
227 | public function find() |
|
228 | { |
|
229 | $this->query->entity(static::$identifier); |
|
230 | ||
231 | // Set entity primary keys if predefined |
|
232 | if (count($this->entityIDs)) { |
|
233 | $this->primary($this->entityIDs); |
|
234 | } |
|
235 | ||
236 | // Add query sorter for showed page |
|
237 | if (count($this->orderBy) === 2) { |
|
238 | $this->query->orderBy($this->orderBy[0], $this->orderBy[1]); |
|
239 | } |
|
240 | ||
241 | // Proxy to regular database query |
|
242 | $return = $this->query |
|
243 | ->whereCondition($this->conditions) |
|
244 | ->exec(); |
|
245 | ||
246 | // Reorder if entity identifiers collection was defined |
|
247 | return $this->sortArrayByArray($return, $this->entityIDs); |
|
248 | } |
|
249 | ||
250 | /** |
|
251 | * Perform SamsonCMS query and get collection of entities fields. |
@@ 106-127 (lines=22) @@ | ||
103 | * |
|
104 | * @return \samsoncms\api\Entity[] Collection of found entities |
|
105 | */ |
|
106 | public function find() |
|
107 | { |
|
108 | $this->query->entity(static::$identifier); |
|
109 | ||
110 | // Set entity primary keys if predefined |
|
111 | if (count($this->entityIDs)) { |
|
112 | $this->primary($this->entityIDs); |
|
113 | } |
|
114 | ||
115 | // Add query sorter for showed page |
|
116 | if (count($this->orderBy) === 2) { |
|
117 | $this->query->orderBy($this->orderBy[0], $this->orderBy[1]); |
|
118 | } |
|
119 | ||
120 | // Proxy to regular database query |
|
121 | $return = $this->query |
|
122 | ->whereCondition($this->conditions) |
|
123 | ->exec(); |
|
124 | ||
125 | // Reorder if entity identifiers collection was defined |
|
126 | return $this->sortArrayByArray($return, $this->entityIDs); |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Add primary field query condition. |