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) |
||
90 | |||
91 | /** |
||
92 | * updateByPk |
||
93 | * |
||
94 | * Update a record and fetch it with its new values. If no records match |
||
95 | * the given key, null is returned. |
||
96 | * |
||
97 | * @access public |
||
98 | * @param array $primary_key |
||
99 | * @param array $updates |
||
100 | * @throws ModelException |
||
101 | * @return FlexibleEntityInterface |
||
102 | */ |
||
103 | public function updateByPk(array $primary_key, array $updates) |
||
138 | |||
139 | /** |
||
140 | * deleteOne |
||
141 | * |
||
142 | * Delete an entity from a table. Entity is passed by reference and is |
||
143 | * updated with the values fetched from the deleted record. |
||
144 | * |
||
145 | * @access public |
||
146 | * @param FlexibleEntityInterface $entity |
||
147 | * @return Model $this |
||
148 | */ |
||
149 | public function deleteOne(FlexibleEntityInterface &$entity) |
||
155 | |||
156 | /** |
||
157 | * deleteByPK |
||
158 | * |
||
159 | * Delete a record from its primary key. The deleted entity is returned or |
||
160 | * null if not found. |
||
161 | * |
||
162 | * @access public |
||
163 | * @param array $primary_key |
||
164 | * @throws ModelException |
||
165 | * @return FlexibleEntityInterface |
||
166 | */ |
||
167 | public function deleteByPK(array $primary_key) |
||
176 | |||
177 | /** |
||
178 | * deleteWhere |
||
179 | * |
||
180 | * Delete records by a given condition. A collection of all deleted entries is returned. |
||
181 | * |
||
182 | * @param $where |
||
183 | * @param array $values |
||
184 | * @return CollectionIterator |
||
185 | */ |
||
186 | public function deleteWhere($where, array $values = []) |
||
209 | |||
210 | /** |
||
211 | * createAndSave |
||
212 | * |
||
213 | * Create a new entity from given values and save it in the database. |
||
214 | * |
||
215 | * @access public |
||
216 | * @param array $values |
||
217 | * @return FlexibleEntityInterface |
||
218 | */ |
||
219 | public function createAndSave(array $values) |
||
226 | |||
227 | /** |
||
228 | * getEscapedFieldList |
||
229 | * |
||
230 | * Return a comma separated list with the given escaped field names. |
||
231 | * |
||
232 | * @access protected |
||
233 | * @param array $fields |
||
234 | * @return string |
||
235 | */ |
||
236 | public function getEscapedFieldList(array $fields) |
||
245 | |||
246 | /** |
||
247 | * getParametersList |
||
248 | * |
||
249 | * Create a parameters list from values. |
||
250 | * |
||
251 | * @access protected |
||
252 | * @param array $values |
||
253 | * @return array $escape codes |
||
254 | */ |
||
255 | protected function getParametersList(array $values) |
||
268 | } |
||
269 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.