ModelInterface.php
7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?php
namespace Phalcon\Mvc {
/**
* Phalcon\Mvc\ModelInterface initializer
*/
interface ModelInterface {
/**
* \Phalcon\Mvc\Model constructor
*
* @param \Phalcon\DiInterface $dependencyInjector
* @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager
*/
public function __construct($dependencyInjector=null, $modelsManager=null);
/**
* Sets a transaction related to the Model instance
*
* @param \Phalcon\Mvc\Model\TransactionInterface $transaction
* @return \Phalcon\Mvc\ModelInterface
*/
public function setTransaction($transaction);
/**
* Returns table name mapped in the model
*
* @return string
*/
public function getSource();
/**
* Returns schema name where table mapped is located
*
* @return string
*/
public function getSchema();
/**
* Sets both read/write connection services
*
* @param string $connectionService
*/
public function setConnectionService($connectionService);
/**
* Sets the DependencyInjection connection service used to write data
*
* @param string $connectionService
*/
public function setWriteConnectionService($connectionService);
/**
* Sets the DependencyInjection connection service used to read data
*
* @param string $connectionService
*/
public function setReadConnectionService($connectionService);
/**
* Returns DependencyInjection connection service used to read data
*
* @return string
*/
public function getReadConnectionService();
/**
* Returns DependencyInjection connection service used to write data
*
* @return string
*/
public function getWriteConnectionService();
/**
* Gets internal database connection
*
* @return \Phalcon\Db\AdapterInterface
*/
public function getReadConnection();
/**
* Gets internal database connection
*
* @return \Phalcon\Db\AdapterInterface
*/
public function getWriteConnection();
/**
* Assigns values to a model from an array
*
* @param \Phalcon\Mvc\Model $object
* @param array $data
* @param array $columnMap
* @return \Phalcon\Mvc\Model
*/
public function assign($data, $columnMap=null);
/**
* Assigns values to a model from an array returning a new model
*
* @param \Phalcon\Mvc\Model $base
* @param array $data
* @param array $columnMap
* @param int $dirtyState
* @param boolean $keepSnapshots
* @return \Phalcon\Mvc\Model $result
*/
public static function cloneResultMap($base, $data, $columnMap, $dirtyState=null, $keepSnapshots=null);
/**
* Assigns values to a model from an array returning a new model
*
* @param \Phalcon\Mvc\Model $base
* @param array $data
* @param int $dirtyState
* @return \Phalcon\Mvc\Model
*/
public static function cloneResult($base, $data, $dirtyState=null);
/**
* Returns an hydrated result based on the data and the column map
*
* @param array $data
* @param array $columnMap
* @param int $hydrationMode
*/
public static function cloneResultMapHydrate($data, $columnMap, $hydrationMode);
/**
* Allows to query a set of records that match the specified conditions
*
* @param array $parameters
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public static function find($parameters=null);
/**
* Allows to query the first record that match the specified conditions
*
* @param array $parameters
* @return \Phalcon\Mvc\ModelInterface
*/
public static function findFirst($parameters=null);
/**
* Create a criteria for a especific model
*
* @param \Phalcon\DiInterface $dependencyInjector
* @return \Phalcon\Mvc\Model\CriteriaInterface
*/
public static function query($dependencyInjector=null);
/**
* Allows to count how many records match the specified conditions
*
* @param array $parameters
* @return int
*/
public static function count($parameters=null);
/**
* Allows to calculate a summatory on a column that match the specified conditions
*
* @param array $parameters
* @return double
*/
public static function sum($parameters=null);
/**
* Allows to get the maximum value of a column that match the specified conditions
*
* @param array $parameters
* @return mixed
*/
public static function maximum($parameters=null);
/**
* Allows to get the minimum value of a column that match the specified conditions
*
* @param array $parameters
* @return mixed
*/
public static function minimum($parameters=null);
/**
* Allows to calculate the average value on a column matching the specified conditions
*
* @param array $parameters
* @return double
*/
public static function average($parameters=null);
/**
* Fires an event, implicitly calls behaviors and listeners in the events manager are notified
*
* @param string $eventName
* @return boolean
*/
public function fireEvent($eventName);
/**
* Fires an event, implicitly calls behaviors and listeners in the events manager are notified
* This method stops if one of the callbacks/listeners returns boolean false
*
* @param string $eventName
* @return boolean
*/
public function fireEventCancel($eventName);
/**
* Appends a customized message on the validation process
*
* @param \Phalcon\Mvc\Model\MessageInterface $message
*/
public function appendMessage($message);
/**
* Check whether validation process has generated any messages
*
* @return boolean
*/
public function validationHasFailed();
/**
* Returns all the validation messages
*
* @return \Phalcon\Mvc\Model\MessageInterface[]
*/
public function getMessages();
/**
* Inserts or updates a model instance. Returning true on success or false otherwise.
*
* @param array $data
* @param array $whiteList
* @return boolean
*/
public function save($data=null, $whiteList=null);
/**
* Inserts a model instance. If the instance already exists in the persistance it will throw an exception
* Returning true on success or false otherwise.
*
* @param array $data
* @param array $whiteList
* @return boolean
*/
public function create($data=null, $whiteList=null);
/**
* Updates a model instance. If the instance doesn't exist in the persistance it will throw an exception
* Returning true on success or false otherwise.
*
* @param array $data
* @param array $whiteList
* @return boolean
*/
public function update($data=null, $whiteList=null);
/**
* Deletes a model instance. Returning true on success or false otherwise.
*
* @return boolean
*/
public function delete();
/**
* Returns the type of the latest operation performed by the ORM
* Returns one of the OP_* class constants
*
* @return int
*/
public function getOperationMade();
/**
* Refreshes the model attributes re-querying the record from the database
*/
public function refresh();
/**
* Reads an attribute value by its name
*
* @param string $attribute
* @return mixed
*/
public function readAttribute($attribute);
/**
* Writes an attribute value by its name
*
* @param string $attribute
* @param mixed $value
*/
public function writeAttribute($attribute, $value);
/**
* Returns related records based on defined relations
*
* @param string $alias
* @param array $arguments
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public function getRelated($alias, $arguments=null);
}
}