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