1 | <?php |
||
28 | trait WriteQueries |
||
29 | { |
||
30 | use ReadQueries; |
||
31 | |||
32 | /** |
||
33 | * insertOne |
||
34 | * |
||
35 | * Insert a new entity in the database. The entity is passed by reference. |
||
36 | * It is updated with values returned by the database (ie, default values). |
||
37 | * |
||
38 | * @access public |
||
39 | * @param FlexibleEntityInterface $entity |
||
40 | * @return Model $this |
||
41 | */ |
||
42 | public function insertOne(FlexibleEntityInterface &$entity) |
||
66 | |||
67 | /** |
||
68 | * updateOne |
||
69 | * |
||
70 | * Update the entity. ONLY the fields indicated in the $fields array are |
||
71 | * updated. The entity is passed by reference and its values are updated |
||
72 | * with the values from the database. This means all changes not updated |
||
73 | * are lost. The update is made upon a condition on the primary key. If the |
||
74 | * primary key is not fully set, an exception is thrown. |
||
75 | * |
||
76 | * @access public |
||
77 | * @param FlexibleEntityInterface $entity |
||
78 | * @param array $fields |
||
79 | * @return Model $this |
||
80 | */ |
||
81 | public function updateOne(FlexibleEntityInterface &$entity, array $fields = []) |
||
94 | |||
95 | /** |
||
96 | * updateByPk |
||
97 | * |
||
98 | * Update a record and fetch it with its new values. If no records match |
||
99 | * the given key, null is returned. |
||
100 | * |
||
101 | * @access public |
||
102 | * @param array $primary_key |
||
103 | * @param array $updates |
||
104 | * @throws ModelException |
||
105 | * @return FlexibleEntityInterface |
||
106 | */ |
||
107 | public function updateByPk(array $primary_key, array $updates) |
||
142 | |||
143 | /** |
||
144 | * deleteOne |
||
145 | * |
||
146 | * Delete an entity from a table. Entity is passed by reference and is |
||
147 | * updated with the values fetched from the deleted record. |
||
148 | * |
||
149 | * @access public |
||
150 | * @param FlexibleEntityInterface $entity |
||
151 | * @return Model $this |
||
152 | */ |
||
153 | public function deleteOne(FlexibleEntityInterface &$entity) |
||
159 | |||
160 | /** |
||
161 | * deleteByPK |
||
162 | * |
||
163 | * Delete a record from its primary key. The deleted entity is returned or |
||
164 | * null if not found. |
||
165 | * |
||
166 | * @access public |
||
167 | * @param array $primary_key |
||
168 | * @throws ModelException |
||
169 | * @return FlexibleEntityInterface |
||
170 | */ |
||
171 | public function deleteByPK(array $primary_key) |
||
180 | |||
181 | /** |
||
182 | * deleteWhere |
||
183 | * |
||
184 | * Delete records by a given condition. A collection of all deleted entries is returned. |
||
185 | * |
||
186 | * @param $where |
||
187 | * @param array $values |
||
188 | * @return CollectionIterator |
||
189 | */ |
||
190 | public function deleteWhere($where, array $values = []) |
||
213 | |||
214 | /** |
||
215 | * truncate |
||
216 | * |
||
217 | * Delete all records. |
||
218 | * |
||
219 | * @param bool $cascade |
||
220 | * @param bool $restart |
||
221 | * @return Model $this |
||
222 | */ |
||
223 | public function truncate($cascade = false, $restart = false) |
||
249 | |||
250 | /** |
||
251 | * createAndSave |
||
252 | * |
||
253 | * Create a new entity from given values and save it in the database. |
||
254 | * |
||
255 | * @access public |
||
256 | * @param array $values |
||
257 | * @return FlexibleEntityInterface |
||
258 | */ |
||
259 | public function createAndSave(array $values) |
||
266 | |||
267 | /** |
||
268 | * getEscapedFieldList |
||
269 | * |
||
270 | * Return a comma separated list with the given escaped field names. |
||
271 | * |
||
272 | * @access protected |
||
273 | * @param array $fields |
||
274 | * @return string |
||
275 | */ |
||
276 | public function getEscapedFieldList(array $fields) |
||
285 | |||
286 | /** |
||
287 | * getParametersList |
||
288 | * |
||
289 | * Create a parameters list from values. |
||
290 | * |
||
291 | * @access protected |
||
292 | * @param array $values |
||
293 | * @return array $escape codes |
||
294 | */ |
||
295 | protected function getParametersList(array $values) |
||
308 | } |
||
309 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.