1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Core\Models\User\Base; |
4
|
|
|
|
5
|
|
|
use \DateTime; |
6
|
|
|
use \Exception; |
7
|
|
|
use \PDO; |
8
|
|
|
use Core\Models\User\UserQuery as ChildUserQuery; |
9
|
|
|
use Core\Models\User\Map\UserTableMap; |
10
|
|
|
use Propel\Runtime\Propel; |
11
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
12
|
|
|
use Propel\Runtime\ActiveQuery\ModelCriteria; |
13
|
|
|
use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
14
|
|
|
use Propel\Runtime\Collection\Collection; |
15
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
16
|
|
|
use Propel\Runtime\Exception\BadMethodCallException; |
17
|
|
|
use Propel\Runtime\Exception\LogicException; |
18
|
|
|
use Propel\Runtime\Exception\PropelException; |
19
|
|
|
use Propel\Runtime\Map\TableMap; |
20
|
|
|
use Propel\Runtime\Parser\AbstractParser; |
21
|
|
|
use Propel\Runtime\Util\PropelDateTime; |
22
|
|
|
use Propel\Runtime\Validator\Constraints\Unique; |
23
|
|
|
use Symfony\Component\Validator\ConstraintValidatorFactory; |
24
|
|
|
use Symfony\Component\Validator\ConstraintViolationList; |
25
|
|
|
use Symfony\Component\Validator\DefaultTranslator; |
26
|
|
|
use Symfony\Component\Validator\Constraints\Email; |
27
|
|
|
use Symfony\Component\Validator\Context\ExecutionContextFactory; |
28
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
29
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadataFactory; |
30
|
|
|
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; |
31
|
|
|
use Symfony\Component\Validator\Validator\LegacyValidator; |
32
|
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Base class that represents a row from the 'users' table. |
36
|
|
|
* |
37
|
|
|
* |
38
|
|
|
* |
39
|
|
|
* @package propel.generator.Models.User.Base |
40
|
|
|
*/ |
41
|
|
|
abstract class User implements ActiveRecordInterface |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* TableMap class name |
45
|
|
|
*/ |
46
|
|
|
const TABLE_MAP = '\\Core\\Models\\User\\Map\\UserTableMap'; |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* attribute to determine if this object has previously been saved. |
51
|
|
|
* @var boolean |
52
|
|
|
*/ |
53
|
|
|
protected $new = true; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* attribute to determine whether this object has been deleted. |
57
|
|
|
* @var boolean |
58
|
|
|
*/ |
59
|
|
|
protected $deleted = false; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* The columns that have been modified in current object. |
63
|
|
|
* Tracking modified columns allows us to only update modified columns. |
64
|
|
|
* @var array |
65
|
|
|
*/ |
66
|
|
|
protected $modifiedColumns = array(); |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* The (virtual) columns that are added at runtime |
70
|
|
|
* The formatters can add supplementary columns based on a resultset |
71
|
|
|
* @var array |
72
|
|
|
*/ |
73
|
|
|
protected $virtualColumns = array(); |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* The value for the id field. |
77
|
|
|
* @var int |
78
|
|
|
*/ |
79
|
|
|
protected $id; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The value for the name field. |
83
|
|
|
* @var string |
84
|
|
|
*/ |
85
|
|
|
protected $name; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* The value for the email field. |
89
|
|
|
* @var string |
90
|
|
|
*/ |
91
|
|
|
protected $email; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The value for the password field. |
95
|
|
|
* @var string |
96
|
|
|
*/ |
97
|
|
|
protected $password; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* The value for the remember_token field. |
101
|
|
|
* @var string |
102
|
|
|
*/ |
103
|
|
|
protected $remember_token; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* The value for the created_at field. |
107
|
|
|
* @var \DateTime |
108
|
|
|
*/ |
109
|
|
|
protected $created_at; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* The value for the updated_at field. |
113
|
|
|
* @var \DateTime |
114
|
|
|
*/ |
115
|
|
|
protected $updated_at; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Flag to prevent endless save loop, if this object is referenced |
119
|
|
|
* by another object which falls in this transaction. |
120
|
|
|
* |
121
|
|
|
* @var boolean |
122
|
|
|
*/ |
123
|
|
|
protected $alreadyInSave = false; |
124
|
|
|
|
125
|
|
|
// validate behavior |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Flag to prevent endless validation loop, if this object is referenced |
129
|
|
|
* by another object which falls in this transaction. |
130
|
|
|
* @var boolean |
131
|
|
|
*/ |
132
|
|
|
protected $alreadyInValidation = false; |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* ConstraintViolationList object |
136
|
|
|
* |
137
|
|
|
* @see http://api.symfony.com/2.0/Symfony/Component/Validator/ConstraintViolationList.html |
138
|
|
|
* @var ConstraintViolationList |
139
|
|
|
*/ |
140
|
|
|
protected $validationFailures; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Initializes internal state of Core\Models\User\Base\User object. |
144
|
|
|
*/ |
145
|
|
|
public function __construct() |
146
|
|
|
{ |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Returns whether the object has been modified. |
151
|
|
|
* |
152
|
|
|
* @return boolean True if the object has been modified. |
153
|
|
|
*/ |
154
|
|
|
public function isModified() |
155
|
|
|
{ |
156
|
|
|
return !!$this->modifiedColumns; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Has specified column been modified? |
161
|
|
|
* |
162
|
|
|
* @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
163
|
|
|
* @return boolean True if $col has been modified. |
164
|
|
|
*/ |
165
|
|
|
public function isColumnModified($col) |
166
|
|
|
{ |
167
|
|
|
return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
|
|
|
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Get the columns that have been modified in this object. |
172
|
|
|
* @return array A unique list of the modified column names for this object. |
173
|
|
|
*/ |
174
|
|
|
public function getModifiedColumns() |
175
|
|
|
{ |
176
|
|
|
return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Returns whether the object has ever been saved. This will |
181
|
|
|
* be false, if the object was retrieved from storage or was created |
182
|
|
|
* and then saved. |
183
|
|
|
* |
184
|
|
|
* @return boolean true, if the object has never been persisted. |
185
|
|
|
*/ |
186
|
|
|
public function isNew() |
187
|
|
|
{ |
188
|
|
|
return $this->new; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Setter for the isNew attribute. This method will be called |
193
|
|
|
* by Propel-generated children and objects. |
194
|
|
|
* |
195
|
|
|
* @param boolean $b the state of the object. |
196
|
|
|
*/ |
197
|
|
|
public function setNew($b) |
198
|
|
|
{ |
199
|
|
|
$this->new = (boolean) $b; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Whether this object has been deleted. |
204
|
|
|
* @return boolean The deleted state of this object. |
205
|
|
|
*/ |
206
|
|
|
public function isDeleted() |
207
|
|
|
{ |
208
|
|
|
return $this->deleted; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Specify whether this object has been deleted. |
213
|
|
|
* @param boolean $b The deleted state of this object. |
214
|
|
|
* @return void |
215
|
|
|
*/ |
216
|
|
|
public function setDeleted($b) |
217
|
|
|
{ |
218
|
|
|
$this->deleted = (boolean) $b; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Sets the modified state for the object to be false. |
223
|
|
|
* @param string $col If supplied, only the specified column is reset. |
224
|
|
|
* @return void |
225
|
|
|
*/ |
226
|
|
View Code Duplication |
public function resetModified($col = null) |
|
|
|
|
227
|
|
|
{ |
228
|
|
|
if (null !== $col) { |
229
|
|
|
if (isset($this->modifiedColumns[$col])) { |
230
|
|
|
unset($this->modifiedColumns[$col]); |
231
|
|
|
} |
232
|
|
|
} else { |
233
|
|
|
$this->modifiedColumns = array(); |
234
|
|
|
} |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Compares this with another <code>User</code> instance. If |
239
|
|
|
* <code>obj</code> is an instance of <code>User</code>, delegates to |
240
|
|
|
* <code>equals(User)</code>. Otherwise, returns <code>false</code>. |
241
|
|
|
* |
242
|
|
|
* @param mixed $obj The object to compare to. |
243
|
|
|
* @return boolean Whether equal to the object specified. |
244
|
|
|
*/ |
245
|
|
View Code Duplication |
public function equals($obj) |
|
|
|
|
246
|
|
|
{ |
247
|
|
|
if (!$obj instanceof static) { |
248
|
|
|
return false; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
if ($this === $obj) { |
252
|
|
|
return true; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
256
|
|
|
return false; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Get the associative array of the virtual columns in this object |
264
|
|
|
* |
265
|
|
|
* @return array |
266
|
|
|
*/ |
267
|
|
|
public function getVirtualColumns() |
268
|
|
|
{ |
269
|
|
|
return $this->virtualColumns; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Checks the existence of a virtual column in this object |
274
|
|
|
* |
275
|
|
|
* @param string $name The virtual column name |
276
|
|
|
* @return boolean |
277
|
|
|
*/ |
278
|
|
|
public function hasVirtualColumn($name) |
279
|
|
|
{ |
280
|
|
|
return array_key_exists($name, $this->virtualColumns); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Get the value of a virtual column in this object |
285
|
|
|
* |
286
|
|
|
* @param string $name The virtual column name |
287
|
|
|
* @return mixed |
288
|
|
|
* |
289
|
|
|
* @throws PropelException |
290
|
|
|
*/ |
291
|
|
View Code Duplication |
public function getVirtualColumn($name) |
|
|
|
|
292
|
|
|
{ |
293
|
|
|
if (!$this->hasVirtualColumn($name)) { |
294
|
|
|
throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
return $this->virtualColumns[$name]; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* Set the value of a virtual column in this object |
302
|
|
|
* |
303
|
|
|
* @param string $name The virtual column name |
304
|
|
|
* @param mixed $value The value to give to the virtual column |
305
|
|
|
* |
306
|
|
|
* @return $this|User The current object, for fluid interface |
307
|
|
|
*/ |
308
|
|
|
public function setVirtualColumn($name, $value) |
309
|
|
|
{ |
310
|
|
|
$this->virtualColumns[$name] = $value; |
311
|
|
|
|
312
|
|
|
return $this; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* Logs a message using Propel::log(). |
317
|
|
|
* |
318
|
|
|
* @param string $msg |
319
|
|
|
* @param int $priority One of the Propel::LOG_* logging levels |
320
|
|
|
* @return boolean |
321
|
|
|
*/ |
322
|
|
|
protected function log($msg, $priority = Propel::LOG_INFO) |
323
|
|
|
{ |
324
|
|
|
return Propel::log(get_class($this) . ': ' . $msg, $priority); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Export the current object properties to a string, using a given parser format |
329
|
|
|
* <code> |
330
|
|
|
* $book = BookQuery::create()->findPk(9012); |
331
|
|
|
* echo $book->exportTo('JSON'); |
332
|
|
|
* => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
333
|
|
|
* </code> |
334
|
|
|
* |
335
|
|
|
* @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
336
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
337
|
|
|
* @return string The exported data |
338
|
|
|
*/ |
339
|
|
View Code Duplication |
public function exportTo($parser, $includeLazyLoadColumns = true) |
|
|
|
|
340
|
|
|
{ |
341
|
|
|
if (!$parser instanceof AbstractParser) { |
342
|
|
|
$parser = AbstractParser::getParser($parser); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
|
|
|
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* Clean up internal collections prior to serializing |
350
|
|
|
* Avoids recursive loops that turn into segmentation faults when serializing |
351
|
|
|
*/ |
352
|
|
|
public function __sleep() |
353
|
|
|
{ |
354
|
|
|
$this->clearAllReferences(); |
|
|
|
|
355
|
|
|
|
356
|
|
|
return array_keys(get_object_vars($this)); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* Get the [id] column value. |
361
|
|
|
* |
362
|
|
|
* @return int |
363
|
|
|
*/ |
364
|
|
|
public function getId() |
365
|
|
|
{ |
366
|
|
|
return $this->id; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Get the [name] column value. |
371
|
|
|
* |
372
|
|
|
* @return string |
373
|
|
|
*/ |
374
|
|
|
public function getName() |
375
|
|
|
{ |
376
|
|
|
return $this->name; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Get the [email] column value. |
381
|
|
|
* |
382
|
|
|
* @return string |
383
|
|
|
*/ |
384
|
|
|
public function getEmail() |
385
|
|
|
{ |
386
|
|
|
return $this->email; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Get the [password] column value. |
391
|
|
|
* |
392
|
|
|
* @return string |
393
|
|
|
*/ |
394
|
|
|
public function getPassword() |
395
|
|
|
{ |
396
|
|
|
return $this->password; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Get the [remember_token] column value. |
401
|
|
|
* |
402
|
|
|
* @return string |
403
|
|
|
*/ |
404
|
|
|
public function getRememberToken() |
405
|
|
|
{ |
406
|
|
|
return $this->remember_token; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Get the [optionally formatted] temporal [created_at] column value. |
411
|
|
|
* |
412
|
|
|
* |
413
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style). |
414
|
|
|
* If format is NULL, then the raw DateTime object will be returned. |
415
|
|
|
* |
416
|
|
|
* @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 |
417
|
|
|
* |
418
|
|
|
* @throws PropelException - if unable to parse/validate the date/time value. |
419
|
|
|
*/ |
420
|
|
View Code Duplication |
public function getCreatedAt($format = NULL) |
|
|
|
|
421
|
|
|
{ |
422
|
|
|
if ($format === null) { |
423
|
|
|
return $this->created_at; |
424
|
|
|
} else { |
425
|
|
|
return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; |
426
|
|
|
} |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Get the [optionally formatted] temporal [updated_at] column value. |
431
|
|
|
* |
432
|
|
|
* |
433
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style). |
434
|
|
|
* If format is NULL, then the raw DateTime object will be returned. |
435
|
|
|
* |
436
|
|
|
* @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 |
437
|
|
|
* |
438
|
|
|
* @throws PropelException - if unable to parse/validate the date/time value. |
439
|
|
|
*/ |
440
|
|
View Code Duplication |
public function getUpdatedAt($format = NULL) |
|
|
|
|
441
|
|
|
{ |
442
|
|
|
if ($format === null) { |
443
|
|
|
return $this->updated_at; |
444
|
|
|
} else { |
445
|
|
|
return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; |
446
|
|
|
} |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* Set the value of [id] column. |
451
|
|
|
* |
452
|
|
|
* @param int $v new value |
453
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
454
|
|
|
*/ |
455
|
|
View Code Duplication |
public function setId($v) |
|
|
|
|
456
|
|
|
{ |
457
|
|
|
if ($v !== null) { |
458
|
|
|
$v = (int) $v; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
if ($this->id !== $v) { |
462
|
|
|
$this->id = $v; |
463
|
|
|
$this->modifiedColumns[UserTableMap::COL_ID] = true; |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
return $this; |
467
|
|
|
} // setId() |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* Set the value of [name] column. |
471
|
|
|
* |
472
|
|
|
* @param string $v new value |
473
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
474
|
|
|
*/ |
475
|
|
View Code Duplication |
public function setName($v) |
|
|
|
|
476
|
|
|
{ |
477
|
|
|
if ($v !== null) { |
478
|
|
|
$v = (string) $v; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
if ($this->name !== $v) { |
482
|
|
|
$this->name = $v; |
483
|
|
|
$this->modifiedColumns[UserTableMap::COL_NAME] = true; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
return $this; |
487
|
|
|
} // setName() |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Set the value of [email] column. |
491
|
|
|
* |
492
|
|
|
* @param string $v new value |
493
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
494
|
|
|
*/ |
495
|
|
View Code Duplication |
public function setEmail($v) |
|
|
|
|
496
|
|
|
{ |
497
|
|
|
if ($v !== null) { |
498
|
|
|
$v = (string) $v; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
if ($this->email !== $v) { |
502
|
|
|
$this->email = $v; |
503
|
|
|
$this->modifiedColumns[UserTableMap::COL_EMAIL] = true; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
return $this; |
507
|
|
|
} // setEmail() |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Set the value of [password] column. |
511
|
|
|
* |
512
|
|
|
* @param string $v new value |
513
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
514
|
|
|
*/ |
515
|
|
View Code Duplication |
public function setPassword($v) |
|
|
|
|
516
|
|
|
{ |
517
|
|
|
if ($v !== null) { |
518
|
|
|
$v = (string) $v; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
if ($this->password !== $v) { |
522
|
|
|
$this->password = $v; |
523
|
|
|
$this->modifiedColumns[UserTableMap::COL_PASSWORD] = true; |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
return $this; |
527
|
|
|
} // setPassword() |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Set the value of [remember_token] column. |
531
|
|
|
* |
532
|
|
|
* @param string $v new value |
533
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
534
|
|
|
*/ |
535
|
|
View Code Duplication |
public function setRememberToken($v) |
|
|
|
|
536
|
|
|
{ |
537
|
|
|
if ($v !== null) { |
538
|
|
|
$v = (string) $v; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
if ($this->remember_token !== $v) { |
542
|
|
|
$this->remember_token = $v; |
543
|
|
|
$this->modifiedColumns[UserTableMap::COL_REMEMBER_TOKEN] = true; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
return $this; |
547
|
|
|
} // setRememberToken() |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* Sets the value of [created_at] column to a normalized version of the date/time value specified. |
551
|
|
|
* |
552
|
|
|
* @param mixed $v string, integer (timestamp), or \DateTime value. |
553
|
|
|
* Empty strings are treated as NULL. |
554
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
555
|
|
|
*/ |
556
|
|
View Code Duplication |
public function setCreatedAt($v) |
|
|
|
|
557
|
|
|
{ |
558
|
|
|
$dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
559
|
|
|
if ($this->created_at !== null || $dt !== null) { |
560
|
|
|
if ($this->created_at === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->created_at->format("Y-m-d H:i:s")) { |
561
|
|
|
$this->created_at = $dt === null ? null : clone $dt; |
|
|
|
|
562
|
|
|
$this->modifiedColumns[UserTableMap::COL_CREATED_AT] = true; |
563
|
|
|
} |
564
|
|
|
} // if either are not null |
565
|
|
|
|
566
|
|
|
return $this; |
567
|
|
|
} // setCreatedAt() |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Sets the value of [updated_at] column to a normalized version of the date/time value specified. |
571
|
|
|
* |
572
|
|
|
* @param mixed $v string, integer (timestamp), or \DateTime value. |
573
|
|
|
* Empty strings are treated as NULL. |
574
|
|
|
* @return $this|\Core\Models\User\User The current object (for fluent API support) |
575
|
|
|
*/ |
576
|
|
View Code Duplication |
public function setUpdatedAt($v) |
|
|
|
|
577
|
|
|
{ |
578
|
|
|
$dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
579
|
|
|
if ($this->updated_at !== null || $dt !== null) { |
580
|
|
|
if ($this->updated_at === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->updated_at->format("Y-m-d H:i:s")) { |
581
|
|
|
$this->updated_at = $dt === null ? null : clone $dt; |
|
|
|
|
582
|
|
|
$this->modifiedColumns[UserTableMap::COL_UPDATED_AT] = true; |
583
|
|
|
} |
584
|
|
|
} // if either are not null |
585
|
|
|
|
586
|
|
|
return $this; |
587
|
|
|
} // setUpdatedAt() |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* Indicates whether the columns in this object are only set to default values. |
591
|
|
|
* |
592
|
|
|
* This method can be used in conjunction with isModified() to indicate whether an object is both |
593
|
|
|
* modified _and_ has some values set which are non-default. |
594
|
|
|
* |
595
|
|
|
* @return boolean Whether the columns in this object are only been set with default values. |
596
|
|
|
*/ |
597
|
|
|
public function hasOnlyDefaultValues() |
598
|
|
|
{ |
599
|
|
|
// otherwise, everything was equal, so return TRUE |
600
|
|
|
return true; |
601
|
|
|
} // hasOnlyDefaultValues() |
602
|
|
|
|
603
|
|
|
/** |
604
|
|
|
* Hydrates (populates) the object variables with values from the database resultset. |
605
|
|
|
* |
606
|
|
|
* An offset (0-based "start column") is specified so that objects can be hydrated |
607
|
|
|
* with a subset of the columns in the resultset rows. This is needed, for example, |
608
|
|
|
* for results of JOIN queries where the resultset row includes columns from two or |
609
|
|
|
* more tables. |
610
|
|
|
* |
611
|
|
|
* @param array $row The row returned by DataFetcher->fetch(). |
612
|
|
|
* @param int $startcol 0-based offset column which indicates which restultset column to start with. |
613
|
|
|
* @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
614
|
|
|
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
615
|
|
|
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
616
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
617
|
|
|
* |
618
|
|
|
* @return int next starting column |
619
|
|
|
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
620
|
|
|
*/ |
621
|
|
|
public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
622
|
|
|
{ |
623
|
|
|
try { |
624
|
|
|
|
625
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : UserTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
626
|
|
|
$this->id = (null !== $col) ? (int) $col : null; |
627
|
|
|
|
628
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
629
|
|
|
$this->name = (null !== $col) ? (string) $col : null; |
630
|
|
|
|
631
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; |
632
|
|
|
$this->email = (null !== $col) ? (string) $col : null; |
633
|
|
|
|
634
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : UserTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; |
635
|
|
|
$this->password = (null !== $col) ? (string) $col : null; |
636
|
|
|
|
637
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : UserTableMap::translateFieldName('RememberToken', TableMap::TYPE_PHPNAME, $indexType)]; |
638
|
|
|
$this->remember_token = (null !== $col) ? (string) $col : null; |
639
|
|
|
|
640
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : UserTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; |
641
|
|
|
if ($col === '0000-00-00 00:00:00') { |
642
|
|
|
$col = null; |
643
|
|
|
} |
644
|
|
|
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
645
|
|
|
|
646
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : UserTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; |
647
|
|
|
if ($col === '0000-00-00 00:00:00') { |
648
|
|
|
$col = null; |
649
|
|
|
} |
650
|
|
|
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
651
|
|
|
$this->resetModified(); |
652
|
|
|
|
653
|
|
|
$this->setNew(false); |
654
|
|
|
|
655
|
|
|
if ($rehydrate) { |
656
|
|
|
$this->ensureConsistency(); |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
return $startcol + 7; // 7 = UserTableMap::NUM_HYDRATE_COLUMNS. |
660
|
|
|
|
661
|
|
|
} catch (Exception $e) { |
662
|
|
|
throw new PropelException(sprintf('Error populating %s object', '\\Core\\Models\\User\\User'), 0, $e); |
663
|
|
|
} |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
/** |
667
|
|
|
* Checks and repairs the internal consistency of the object. |
668
|
|
|
* |
669
|
|
|
* This method is executed after an already-instantiated object is re-hydrated |
670
|
|
|
* from the database. It exists to check any foreign keys to make sure that |
671
|
|
|
* the objects related to the current object are correct based on foreign key. |
672
|
|
|
* |
673
|
|
|
* You can override this method in the stub class, but you should always invoke |
674
|
|
|
* the base method from the overridden method (i.e. parent::ensureConsistency()), |
675
|
|
|
* in case your model changes. |
676
|
|
|
* |
677
|
|
|
* @throws PropelException |
678
|
|
|
*/ |
679
|
|
|
public function ensureConsistency() |
680
|
|
|
{ |
681
|
|
|
} // ensureConsistency |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
685
|
|
|
* |
686
|
|
|
* This will only work if the object has been saved and has a valid primary key set. |
687
|
|
|
* |
688
|
|
|
* @param boolean $deep (optional) Whether to also de-associated any related objects. |
689
|
|
|
* @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
690
|
|
|
* @return void |
691
|
|
|
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
692
|
|
|
*/ |
693
|
|
View Code Duplication |
public function reload($deep = false, ConnectionInterface $con = null) |
|
|
|
|
694
|
|
|
{ |
695
|
|
|
if ($this->isDeleted()) { |
696
|
|
|
throw new PropelException("Cannot reload a deleted object."); |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
if ($this->isNew()) { |
700
|
|
|
throw new PropelException("Cannot reload an unsaved object."); |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
if ($con === null) { |
704
|
|
|
$con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME); |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
// We don't need to alter the object instance pool; we're just modifying this instance |
708
|
|
|
// already in the pool. |
709
|
|
|
|
710
|
|
|
$dataFetcher = ChildUserQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
|
|
|
711
|
|
|
$row = $dataFetcher->fetch(); |
712
|
|
|
$dataFetcher->close(); |
713
|
|
|
if (!$row) { |
714
|
|
|
throw new PropelException('Cannot find matching row in the database to reload object values.'); |
715
|
|
|
} |
716
|
|
|
$this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
717
|
|
|
|
718
|
|
|
if ($deep) { // also de-associate any related objects? |
|
|
|
|
719
|
|
|
|
720
|
|
|
} // if (deep) |
|
|
|
|
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
/** |
724
|
|
|
* Removes this object from datastore and sets delete attribute. |
725
|
|
|
* |
726
|
|
|
* @param ConnectionInterface $con |
727
|
|
|
* @return void |
728
|
|
|
* @throws PropelException |
729
|
|
|
* @see User::setDeleted() |
730
|
|
|
* @see User::isDeleted() |
731
|
|
|
*/ |
732
|
|
View Code Duplication |
public function delete(ConnectionInterface $con = null) |
|
|
|
|
733
|
|
|
{ |
734
|
|
|
if ($this->isDeleted()) { |
735
|
|
|
throw new PropelException("This object has already been deleted."); |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
if ($con === null) { |
739
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
740
|
|
|
} |
741
|
|
|
|
742
|
|
|
$con->transaction(function () use ($con) { |
743
|
|
|
$deleteQuery = ChildUserQuery::create() |
744
|
|
|
->filterByPrimaryKey($this->getPrimaryKey()); |
745
|
|
|
$ret = $this->preDelete($con); |
746
|
|
|
if ($ret) { |
747
|
|
|
$deleteQuery->delete($con); |
748
|
|
|
$this->postDelete($con); |
749
|
|
|
$this->setDeleted(true); |
750
|
|
|
} |
751
|
|
|
}); |
752
|
|
|
} |
753
|
|
|
|
754
|
|
|
/** |
755
|
|
|
* Persists this object to the database. |
756
|
|
|
* |
757
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
758
|
|
|
* All modified related objects will also be persisted in the doSave() |
759
|
|
|
* method. This method wraps all precipitate database operations in a |
760
|
|
|
* single transaction. |
761
|
|
|
* |
762
|
|
|
* @param ConnectionInterface $con |
763
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
764
|
|
|
* @throws PropelException |
765
|
|
|
* @see doSave() |
766
|
|
|
*/ |
767
|
|
View Code Duplication |
public function save(ConnectionInterface $con = null) |
|
|
|
|
768
|
|
|
{ |
769
|
|
|
if ($this->isDeleted()) { |
770
|
|
|
throw new PropelException("You cannot save an object that has been deleted."); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
if ($con === null) { |
774
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
return $con->transaction(function () use ($con) { |
778
|
|
|
$isInsert = $this->isNew(); |
779
|
|
|
$ret = $this->preSave($con); |
780
|
|
|
if ($isInsert) { |
781
|
|
|
$ret = $ret && $this->preInsert($con); |
782
|
|
|
} else { |
783
|
|
|
$ret = $ret && $this->preUpdate($con); |
784
|
|
|
} |
785
|
|
|
if ($ret) { |
786
|
|
|
$affectedRows = $this->doSave($con); |
787
|
|
|
if ($isInsert) { |
788
|
|
|
$this->postInsert($con); |
789
|
|
|
} else { |
790
|
|
|
$this->postUpdate($con); |
791
|
|
|
} |
792
|
|
|
$this->postSave($con); |
793
|
|
|
UserTableMap::addInstanceToPool($this); |
794
|
|
|
} else { |
795
|
|
|
$affectedRows = 0; |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
return $affectedRows; |
799
|
|
|
}); |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
/** |
803
|
|
|
* Performs the work of inserting or updating the row in the database. |
804
|
|
|
* |
805
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
806
|
|
|
* All related objects are also updated in this method. |
807
|
|
|
* |
808
|
|
|
* @param ConnectionInterface $con |
809
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
810
|
|
|
* @throws PropelException |
811
|
|
|
* @see save() |
812
|
|
|
*/ |
813
|
|
View Code Duplication |
protected function doSave(ConnectionInterface $con) |
|
|
|
|
814
|
|
|
{ |
815
|
|
|
$affectedRows = 0; // initialize var to track total num of affected rows |
816
|
|
|
if (!$this->alreadyInSave) { |
817
|
|
|
$this->alreadyInSave = true; |
818
|
|
|
|
819
|
|
|
if ($this->isNew() || $this->isModified()) { |
820
|
|
|
// persist changes |
821
|
|
|
if ($this->isNew()) { |
822
|
|
|
$this->doInsert($con); |
823
|
|
|
$affectedRows += 1; |
824
|
|
|
} else { |
825
|
|
|
$affectedRows += $this->doUpdate($con); |
826
|
|
|
} |
827
|
|
|
$this->resetModified(); |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
$this->alreadyInSave = false; |
831
|
|
|
|
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
return $affectedRows; |
835
|
|
|
} // doSave() |
836
|
|
|
|
837
|
|
|
/** |
838
|
|
|
* Insert the row in the database. |
839
|
|
|
* |
840
|
|
|
* @param ConnectionInterface $con |
841
|
|
|
* |
842
|
|
|
* @throws PropelException |
843
|
|
|
* @see doSave() |
844
|
|
|
*/ |
845
|
|
|
protected function doInsert(ConnectionInterface $con) |
846
|
|
|
{ |
847
|
|
|
$modifiedColumns = array(); |
848
|
|
|
$index = 0; |
849
|
|
|
|
850
|
|
|
$this->modifiedColumns[UserTableMap::COL_ID] = true; |
851
|
|
|
if (null !== $this->id) { |
852
|
|
|
throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')'); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
// check the columns in natural order for more readable SQL queries |
856
|
|
|
if ($this->isColumnModified(UserTableMap::COL_ID)) { |
857
|
|
|
$modifiedColumns[':p' . $index++] = 'id'; |
858
|
|
|
} |
859
|
|
|
if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
860
|
|
|
$modifiedColumns[':p' . $index++] = 'name'; |
861
|
|
|
} |
862
|
|
|
if ($this->isColumnModified(UserTableMap::COL_EMAIL)) { |
863
|
|
|
$modifiedColumns[':p' . $index++] = 'email'; |
864
|
|
|
} |
865
|
|
|
if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) { |
866
|
|
|
$modifiedColumns[':p' . $index++] = 'password'; |
867
|
|
|
} |
868
|
|
|
if ($this->isColumnModified(UserTableMap::COL_REMEMBER_TOKEN)) { |
869
|
|
|
$modifiedColumns[':p' . $index++] = 'remember_token'; |
870
|
|
|
} |
871
|
|
|
if ($this->isColumnModified(UserTableMap::COL_CREATED_AT)) { |
872
|
|
|
$modifiedColumns[':p' . $index++] = 'created_at'; |
873
|
|
|
} |
874
|
|
|
if ($this->isColumnModified(UserTableMap::COL_UPDATED_AT)) { |
875
|
|
|
$modifiedColumns[':p' . $index++] = 'updated_at'; |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
$sql = sprintf( |
879
|
|
|
'INSERT INTO users (%s) VALUES (%s)', |
880
|
|
|
implode(', ', $modifiedColumns), |
881
|
|
|
implode(', ', array_keys($modifiedColumns)) |
882
|
|
|
); |
883
|
|
|
|
884
|
|
|
try { |
885
|
|
|
$stmt = $con->prepare($sql); |
886
|
|
|
foreach ($modifiedColumns as $identifier => $columnName) { |
887
|
|
|
switch ($columnName) { |
888
|
|
|
case 'id': |
889
|
|
|
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
890
|
|
|
break; |
891
|
|
|
case 'name': |
892
|
|
|
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
893
|
|
|
break; |
894
|
|
|
case 'email': |
895
|
|
|
$stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); |
896
|
|
|
break; |
897
|
|
|
case 'password': |
898
|
|
|
$stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); |
899
|
|
|
break; |
900
|
|
|
case 'remember_token': |
901
|
|
|
$stmt->bindValue($identifier, $this->remember_token, PDO::PARAM_STR); |
902
|
|
|
break; |
903
|
|
|
case 'created_at': |
904
|
|
|
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
905
|
|
|
break; |
906
|
|
|
case 'updated_at': |
907
|
|
|
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
908
|
|
|
break; |
909
|
|
|
} |
910
|
|
|
} |
911
|
|
|
$stmt->execute(); |
912
|
|
|
} catch (Exception $e) { |
913
|
|
|
Propel::log($e->getMessage(), Propel::LOG_ERR); |
914
|
|
|
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
915
|
|
|
} |
916
|
|
|
|
917
|
|
|
try { |
918
|
|
|
$pk = $con->lastInsertId(); |
919
|
|
|
} catch (Exception $e) { |
920
|
|
|
throw new PropelException('Unable to get autoincrement id.', 0, $e); |
921
|
|
|
} |
922
|
|
|
$this->setId($pk); |
923
|
|
|
|
924
|
|
|
$this->setNew(false); |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
/** |
928
|
|
|
* Update the row in the database. |
929
|
|
|
* |
930
|
|
|
* @param ConnectionInterface $con |
931
|
|
|
* |
932
|
|
|
* @return Integer Number of updated rows |
933
|
|
|
* @see doSave() |
934
|
|
|
*/ |
935
|
|
|
protected function doUpdate(ConnectionInterface $con) |
936
|
|
|
{ |
937
|
|
|
$selectCriteria = $this->buildPkeyCriteria(); |
938
|
|
|
$valuesCriteria = $this->buildCriteria(); |
939
|
|
|
|
940
|
|
|
return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
|
|
|
941
|
|
|
} |
942
|
|
|
|
943
|
|
|
/** |
944
|
|
|
* Retrieves a field from the object by name passed in as a string. |
945
|
|
|
* |
946
|
|
|
* @param string $name name |
947
|
|
|
* @param string $type The type of fieldname the $name is of: |
948
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
949
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
950
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
951
|
|
|
* @return mixed Value of field. |
952
|
|
|
*/ |
953
|
|
View Code Duplication |
public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
|
|
|
954
|
|
|
{ |
955
|
|
|
$pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
956
|
|
|
$field = $this->getByPosition($pos); |
957
|
|
|
|
958
|
|
|
return $field; |
959
|
|
|
} |
960
|
|
|
|
961
|
|
|
/** |
962
|
|
|
* Retrieves a field from the object by Position as specified in the xml schema. |
963
|
|
|
* Zero-based. |
964
|
|
|
* |
965
|
|
|
* @param int $pos position in xml schema |
966
|
|
|
* @return mixed Value of field at $pos |
967
|
|
|
*/ |
968
|
|
|
public function getByPosition($pos) |
969
|
|
|
{ |
970
|
|
|
switch ($pos) { |
971
|
|
|
case 0: |
972
|
|
|
return $this->getId(); |
973
|
|
|
break; |
|
|
|
|
974
|
|
|
case 1: |
975
|
|
|
return $this->getName(); |
976
|
|
|
break; |
|
|
|
|
977
|
|
|
case 2: |
978
|
|
|
return $this->getEmail(); |
979
|
|
|
break; |
|
|
|
|
980
|
|
|
case 3: |
981
|
|
|
return $this->getPassword(); |
982
|
|
|
break; |
|
|
|
|
983
|
|
|
case 4: |
984
|
|
|
return $this->getRememberToken(); |
985
|
|
|
break; |
|
|
|
|
986
|
|
|
case 5: |
987
|
|
|
return $this->getCreatedAt(); |
988
|
|
|
break; |
|
|
|
|
989
|
|
|
case 6: |
990
|
|
|
return $this->getUpdatedAt(); |
991
|
|
|
break; |
|
|
|
|
992
|
|
|
default: |
993
|
|
|
return null; |
994
|
|
|
break; |
|
|
|
|
995
|
|
|
} // switch() |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* Exports the object as an array. |
1000
|
|
|
* |
1001
|
|
|
* You can specify the key type of the array by passing one of the class |
1002
|
|
|
* type constants. |
1003
|
|
|
* |
1004
|
|
|
* @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1005
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1006
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
1007
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
1008
|
|
|
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
1009
|
|
|
* |
1010
|
|
|
* @return array an associative array containing the field names (as keys) and field values |
1011
|
|
|
*/ |
1012
|
|
|
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) |
|
|
|
|
1013
|
|
|
{ |
1014
|
|
|
|
1015
|
|
|
if (isset($alreadyDumpedObjects['User'][$this->hashCode()])) { |
1016
|
|
|
return '*RECURSION*'; |
1017
|
|
|
} |
1018
|
|
|
$alreadyDumpedObjects['User'][$this->hashCode()] = true; |
1019
|
|
|
$keys = UserTableMap::getFieldNames($keyType); |
1020
|
|
|
$result = array( |
1021
|
|
|
$keys[0] => $this->getId(), |
1022
|
|
|
$keys[1] => $this->getName(), |
1023
|
|
|
$keys[2] => $this->getEmail(), |
1024
|
|
|
$keys[3] => $this->getPassword(), |
1025
|
|
|
$keys[4] => $this->getRememberToken(), |
1026
|
|
|
$keys[5] => $this->getCreatedAt(), |
1027
|
|
|
$keys[6] => $this->getUpdatedAt(), |
1028
|
|
|
); |
1029
|
|
|
|
1030
|
|
|
$utc = new \DateTimeZone('utc'); |
1031
|
|
View Code Duplication |
if ($result[$keys[5]] instanceof \DateTime) { |
|
|
|
|
1032
|
|
|
// When changing timezone we don't want to change existing instances |
1033
|
|
|
$dateTime = clone $result[$keys[5]]; |
1034
|
|
|
$result[$keys[5]] = $dateTime->setTimezone($utc)->format('Y-m-d\TH:i:s\Z'); |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
|
View Code Duplication |
if ($result[$keys[6]] instanceof \DateTime) { |
|
|
|
|
1038
|
|
|
// When changing timezone we don't want to change existing instances |
1039
|
|
|
$dateTime = clone $result[$keys[6]]; |
1040
|
|
|
$result[$keys[6]] = $dateTime->setTimezone($utc)->format('Y-m-d\TH:i:s\Z'); |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
$virtualColumns = $this->virtualColumns; |
1044
|
|
|
foreach ($virtualColumns as $key => $virtualColumn) { |
1045
|
|
|
$result[$key] = $virtualColumn; |
1046
|
|
|
} |
1047
|
|
|
|
1048
|
|
|
|
1049
|
|
|
return $result; |
1050
|
|
|
} |
1051
|
|
|
|
1052
|
|
|
/** |
1053
|
|
|
* Sets a field from the object by name passed in as a string. |
1054
|
|
|
* |
1055
|
|
|
* @param string $name |
1056
|
|
|
* @param mixed $value field value |
1057
|
|
|
* @param string $type The type of fieldname the $name is of: |
1058
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
1059
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1060
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
1061
|
|
|
* @return $this|\Core\Models\User\User |
1062
|
|
|
*/ |
1063
|
|
|
public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
1064
|
|
|
{ |
1065
|
|
|
$pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
1066
|
|
|
|
1067
|
|
|
return $this->setByPosition($pos, $value); |
1068
|
|
|
} |
1069
|
|
|
|
1070
|
|
|
/** |
1071
|
|
|
* Sets a field from the object by Position as specified in the xml schema. |
1072
|
|
|
* Zero-based. |
1073
|
|
|
* |
1074
|
|
|
* @param int $pos position in xml schema |
1075
|
|
|
* @param mixed $value field value |
1076
|
|
|
* @return $this|\Core\Models\User\User |
1077
|
|
|
*/ |
1078
|
|
|
public function setByPosition($pos, $value) |
1079
|
|
|
{ |
1080
|
|
|
switch ($pos) { |
1081
|
|
|
case 0: |
1082
|
|
|
$this->setId($value); |
1083
|
|
|
break; |
1084
|
|
|
case 1: |
1085
|
|
|
$this->setName($value); |
1086
|
|
|
break; |
1087
|
|
|
case 2: |
1088
|
|
|
$this->setEmail($value); |
1089
|
|
|
break; |
1090
|
|
|
case 3: |
1091
|
|
|
$this->setPassword($value); |
1092
|
|
|
break; |
1093
|
|
|
case 4: |
1094
|
|
|
$this->setRememberToken($value); |
1095
|
|
|
break; |
1096
|
|
|
case 5: |
1097
|
|
|
$this->setCreatedAt($value); |
1098
|
|
|
break; |
1099
|
|
|
case 6: |
1100
|
|
|
$this->setUpdatedAt($value); |
1101
|
|
|
break; |
1102
|
|
|
} // switch() |
1103
|
|
|
|
1104
|
|
|
return $this; |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
/** |
1108
|
|
|
* Populates the object using an array. |
1109
|
|
|
* |
1110
|
|
|
* This is particularly useful when populating an object from one of the |
1111
|
|
|
* request arrays (e.g. $_POST). This method goes through the column |
1112
|
|
|
* names, checking to see whether a matching key exists in populated |
1113
|
|
|
* array. If so the setByName() method is called for that column. |
1114
|
|
|
* |
1115
|
|
|
* You can specify the key type of the array by additionally passing one |
1116
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1117
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1118
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
1119
|
|
|
* |
1120
|
|
|
* @param array $arr An array to populate the object from. |
1121
|
|
|
* @param string $keyType The type of keys the array uses. |
1122
|
|
|
* @return void |
1123
|
|
|
*/ |
1124
|
|
|
public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
1125
|
|
|
{ |
1126
|
|
|
$keys = UserTableMap::getFieldNames($keyType); |
1127
|
|
|
|
1128
|
|
|
if (array_key_exists($keys[0], $arr)) { |
1129
|
|
|
$this->setId($arr[$keys[0]]); |
1130
|
|
|
} |
1131
|
|
|
if (array_key_exists($keys[1], $arr)) { |
1132
|
|
|
$this->setName($arr[$keys[1]]); |
1133
|
|
|
} |
1134
|
|
|
if (array_key_exists($keys[2], $arr)) { |
1135
|
|
|
$this->setEmail($arr[$keys[2]]); |
1136
|
|
|
} |
1137
|
|
|
if (array_key_exists($keys[3], $arr)) { |
1138
|
|
|
$this->setPassword($arr[$keys[3]]); |
1139
|
|
|
} |
1140
|
|
|
if (array_key_exists($keys[4], $arr)) { |
1141
|
|
|
$this->setRememberToken($arr[$keys[4]]); |
1142
|
|
|
} |
1143
|
|
|
if (array_key_exists($keys[5], $arr)) { |
1144
|
|
|
$this->setCreatedAt($arr[$keys[5]]); |
1145
|
|
|
} |
1146
|
|
|
if (array_key_exists($keys[6], $arr)) { |
1147
|
|
|
$this->setUpdatedAt($arr[$keys[6]]); |
1148
|
|
|
} |
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
/** |
1152
|
|
|
* Populate the current object from a string, using a given parser format |
1153
|
|
|
* <code> |
1154
|
|
|
* $book = new Book(); |
1155
|
|
|
* $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
1156
|
|
|
* </code> |
1157
|
|
|
* |
1158
|
|
|
* You can specify the key type of the array by additionally passing one |
1159
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1160
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1161
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
1162
|
|
|
* |
1163
|
|
|
* @param mixed $parser A AbstractParser instance, |
1164
|
|
|
* or a format name ('XML', 'YAML', 'JSON', 'CSV') |
1165
|
|
|
* @param string $data The source data to import from |
1166
|
|
|
* @param string $keyType The type of keys the array uses. |
1167
|
|
|
* |
1168
|
|
|
* @return $this|\Core\Models\User\User The current object, for fluid interface |
1169
|
|
|
*/ |
1170
|
|
View Code Duplication |
public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
|
|
|
1171
|
|
|
{ |
1172
|
|
|
if (!$parser instanceof AbstractParser) { |
1173
|
|
|
$parser = AbstractParser::getParser($parser); |
1174
|
|
|
} |
1175
|
|
|
|
1176
|
|
|
$this->fromArray($parser->toArray($data), $keyType); |
1177
|
|
|
|
1178
|
|
|
return $this; |
1179
|
|
|
} |
1180
|
|
|
|
1181
|
|
|
/** |
1182
|
|
|
* Build a Criteria object containing the values of all modified columns in this object. |
1183
|
|
|
* |
1184
|
|
|
* @return Criteria The Criteria object containing all modified values. |
1185
|
|
|
*/ |
1186
|
|
|
public function buildCriteria() |
1187
|
|
|
{ |
1188
|
|
|
$criteria = new Criteria(UserTableMap::DATABASE_NAME); |
1189
|
|
|
|
1190
|
|
|
if ($this->isColumnModified(UserTableMap::COL_ID)) { |
1191
|
|
|
$criteria->add(UserTableMap::COL_ID, $this->id); |
1192
|
|
|
} |
1193
|
|
|
if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
1194
|
|
|
$criteria->add(UserTableMap::COL_NAME, $this->name); |
1195
|
|
|
} |
1196
|
|
|
if ($this->isColumnModified(UserTableMap::COL_EMAIL)) { |
1197
|
|
|
$criteria->add(UserTableMap::COL_EMAIL, $this->email); |
1198
|
|
|
} |
1199
|
|
|
if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) { |
1200
|
|
|
$criteria->add(UserTableMap::COL_PASSWORD, $this->password); |
1201
|
|
|
} |
1202
|
|
|
if ($this->isColumnModified(UserTableMap::COL_REMEMBER_TOKEN)) { |
1203
|
|
|
$criteria->add(UserTableMap::COL_REMEMBER_TOKEN, $this->remember_token); |
1204
|
|
|
} |
1205
|
|
|
if ($this->isColumnModified(UserTableMap::COL_CREATED_AT)) { |
1206
|
|
|
$criteria->add(UserTableMap::COL_CREATED_AT, $this->created_at); |
1207
|
|
|
} |
1208
|
|
|
if ($this->isColumnModified(UserTableMap::COL_UPDATED_AT)) { |
1209
|
|
|
$criteria->add(UserTableMap::COL_UPDATED_AT, $this->updated_at); |
1210
|
|
|
} |
1211
|
|
|
|
1212
|
|
|
return $criteria; |
1213
|
|
|
} |
1214
|
|
|
|
1215
|
|
|
/** |
1216
|
|
|
* Builds a Criteria object containing the primary key for this object. |
1217
|
|
|
* |
1218
|
|
|
* Unlike buildCriteria() this method includes the primary key values regardless |
1219
|
|
|
* of whether or not they have been modified. |
1220
|
|
|
* |
1221
|
|
|
* @throws LogicException if no primary key is defined |
1222
|
|
|
* |
1223
|
|
|
* @return Criteria The Criteria object containing value(s) for primary key(s). |
1224
|
|
|
*/ |
1225
|
|
|
public function buildPkeyCriteria() |
1226
|
|
|
{ |
1227
|
|
|
$criteria = ChildUserQuery::create(); |
1228
|
|
|
$criteria->add(UserTableMap::COL_ID, $this->id); |
1229
|
|
|
|
1230
|
|
|
return $criteria; |
1231
|
|
|
} |
1232
|
|
|
|
1233
|
|
|
/** |
1234
|
|
|
* If the primary key is not null, return the hashcode of the |
1235
|
|
|
* primary key. Otherwise, return the hash code of the object. |
1236
|
|
|
* |
1237
|
|
|
* @return int Hashcode |
1238
|
|
|
*/ |
1239
|
|
View Code Duplication |
public function hashCode() |
|
|
|
|
1240
|
|
|
{ |
1241
|
|
|
$validPk = null !== $this->getId(); |
1242
|
|
|
|
1243
|
|
|
$validPrimaryKeyFKs = 0; |
1244
|
|
|
$primaryKeyFKs = []; |
1245
|
|
|
|
1246
|
|
|
if ($validPk) { |
1247
|
|
|
return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
1248
|
|
|
} elseif ($validPrimaryKeyFKs) { |
1249
|
|
|
return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
return spl_object_hash($this); |
1253
|
|
|
} |
1254
|
|
|
|
1255
|
|
|
/** |
1256
|
|
|
* Returns the primary key for this object (row). |
1257
|
|
|
* @return int |
1258
|
|
|
*/ |
1259
|
|
|
public function getPrimaryKey() |
1260
|
|
|
{ |
1261
|
|
|
return $this->getId(); |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
/** |
1265
|
|
|
* Generic method to set the primary key (id column). |
1266
|
|
|
* |
1267
|
|
|
* @param int $key Primary key. |
1268
|
|
|
* @return void |
1269
|
|
|
*/ |
1270
|
|
|
public function setPrimaryKey($key) |
1271
|
|
|
{ |
1272
|
|
|
$this->setId($key); |
1273
|
|
|
} |
1274
|
|
|
|
1275
|
|
|
/** |
1276
|
|
|
* Returns true if the primary key for this object is null. |
1277
|
|
|
* @return boolean |
1278
|
|
|
*/ |
1279
|
|
|
public function isPrimaryKeyNull() |
1280
|
|
|
{ |
1281
|
|
|
return null === $this->getId(); |
1282
|
|
|
} |
1283
|
|
|
|
1284
|
|
|
/** |
1285
|
|
|
* Sets contents of passed object to values from current object. |
1286
|
|
|
* |
1287
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
1288
|
|
|
* objects. |
1289
|
|
|
* |
1290
|
|
|
* @param object $copyObj An object of \Core\Models\User\User (or compatible) type. |
1291
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
1292
|
|
|
* @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
1293
|
|
|
* @throws PropelException |
1294
|
|
|
*/ |
1295
|
|
|
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
|
|
|
1296
|
|
|
{ |
1297
|
|
|
$copyObj->setName($this->getName()); |
1298
|
|
|
$copyObj->setEmail($this->getEmail()); |
1299
|
|
|
$copyObj->setPassword($this->getPassword()); |
1300
|
|
|
$copyObj->setRememberToken($this->getRememberToken()); |
1301
|
|
|
$copyObj->setCreatedAt($this->getCreatedAt()); |
1302
|
|
|
$copyObj->setUpdatedAt($this->getUpdatedAt()); |
1303
|
|
|
if ($makeNew) { |
1304
|
|
|
$copyObj->setNew(true); |
1305
|
|
|
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
1306
|
|
|
} |
1307
|
|
|
} |
1308
|
|
|
|
1309
|
|
|
/** |
1310
|
|
|
* Makes a copy of this object that will be inserted as a new row in table when saved. |
1311
|
|
|
* It creates a new object filling in the simple attributes, but skipping any primary |
1312
|
|
|
* keys that are defined for the table. |
1313
|
|
|
* |
1314
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
1315
|
|
|
* objects. |
1316
|
|
|
* |
1317
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
1318
|
|
|
* @return \Core\Models\User\User Clone of current object. |
1319
|
|
|
* @throws PropelException |
1320
|
|
|
*/ |
1321
|
|
View Code Duplication |
public function copy($deepCopy = false) |
|
|
|
|
1322
|
|
|
{ |
1323
|
|
|
// we use get_class(), because this might be a subclass |
1324
|
|
|
$clazz = get_class($this); |
1325
|
|
|
$copyObj = new $clazz(); |
1326
|
|
|
$this->copyInto($copyObj, $deepCopy); |
1327
|
|
|
|
1328
|
|
|
return $copyObj; |
1329
|
|
|
} |
1330
|
|
|
|
1331
|
|
|
/** |
1332
|
|
|
* Clears the current object, sets all attributes to their default values and removes |
1333
|
|
|
* outgoing references as well as back-references (from other objects to this one. Results probably in a database |
1334
|
|
|
* change of those foreign objects when you call `save` there). |
1335
|
|
|
*/ |
1336
|
|
|
public function clear() |
1337
|
|
|
{ |
1338
|
|
|
$this->id = null; |
1339
|
|
|
$this->name = null; |
1340
|
|
|
$this->email = null; |
1341
|
|
|
$this->password = null; |
1342
|
|
|
$this->remember_token = null; |
1343
|
|
|
$this->created_at = null; |
1344
|
|
|
$this->updated_at = null; |
1345
|
|
|
$this->alreadyInSave = false; |
1346
|
|
|
$this->clearAllReferences(); |
|
|
|
|
1347
|
|
|
$this->resetModified(); |
1348
|
|
|
$this->setNew(true); |
1349
|
|
|
$this->setDeleted(false); |
1350
|
|
|
} |
1351
|
|
|
|
1352
|
|
|
/** |
1353
|
|
|
* Resets all references and back-references to other model objects or collections of model objects. |
1354
|
|
|
* |
1355
|
|
|
* This method is used to reset all php object references (not the actual reference in the database). |
1356
|
|
|
* Necessary for object serialisation. |
1357
|
|
|
* |
1358
|
|
|
* @param boolean $deep Whether to also clear the references on all referrer objects. |
1359
|
|
|
*/ |
1360
|
|
|
public function clearAllReferences($deep = false) |
1361
|
|
|
{ |
1362
|
|
|
if ($deep) { |
|
|
|
|
1363
|
|
|
} // if ($deep) |
|
|
|
|
1364
|
|
|
|
1365
|
|
|
} |
1366
|
|
|
|
1367
|
|
|
/** |
1368
|
|
|
* Return the string representation of this object |
1369
|
|
|
* |
1370
|
|
|
* @return string |
1371
|
|
|
*/ |
1372
|
|
|
public function __toString() |
1373
|
|
|
{ |
1374
|
|
|
return (string) $this->exportTo(UserTableMap::DEFAULT_STRING_FORMAT); |
1375
|
|
|
} |
1376
|
|
|
|
1377
|
|
|
// validate behavior |
1378
|
|
|
|
1379
|
|
|
/** |
1380
|
|
|
* Configure validators constraints. The Validator object uses this method |
1381
|
|
|
* to perform object validation. |
1382
|
|
|
* |
1383
|
|
|
* @param ClassMetadata $metadata |
1384
|
|
|
*/ |
1385
|
|
|
static public function loadValidatorMetadata(ClassMetadata $metadata) |
|
|
|
|
1386
|
|
|
{ |
1387
|
|
|
$metadata->addPropertyConstraint('email', new Email(array ('message' => 'поле Email не заполнено',))); |
1388
|
|
|
$metadata->addPropertyConstraint('email', new Unique(array ('message' => 'Email должен быть уникален',))); |
1389
|
|
|
} |
1390
|
|
|
|
1391
|
|
|
/** |
1392
|
|
|
* Validates the object and all objects related to this table. |
1393
|
|
|
* |
1394
|
|
|
* @see getValidationFailures() |
1395
|
|
|
* @param object $validator A Validator class instance |
1396
|
|
|
* @return boolean Whether all objects pass validation. |
1397
|
|
|
*/ |
1398
|
|
|
public function validate(ValidatorInterface $validator = null) |
1399
|
|
|
{ |
1400
|
|
|
if (null === $validator) { |
1401
|
|
|
if(class_exists('Symfony\\Component\\Validator\\Validator\\LegacyValidator')){ |
1402
|
|
|
$validator = new LegacyValidator( |
1403
|
|
|
new ExecutionContextFactory(new DefaultTranslator()), |
1404
|
|
|
new ClassMetaDataFactory(new StaticMethodLoader()), |
1405
|
|
|
new ConstraintValidatorFactory() |
1406
|
|
|
); |
1407
|
|
|
}else{ |
1408
|
|
|
$validator = new Validator( |
1409
|
|
|
new ClassMetadataFactory(new StaticMethodLoader()), |
1410
|
|
|
new ConstraintValidatorFactory(), |
1411
|
|
|
new DefaultTranslator() |
1412
|
|
|
); |
1413
|
|
|
} |
1414
|
|
|
} |
1415
|
|
|
|
1416
|
|
|
$failureMap = new ConstraintViolationList(); |
1417
|
|
|
|
1418
|
|
|
if (!$this->alreadyInValidation) { |
1419
|
|
|
$this->alreadyInValidation = true; |
1420
|
|
|
$retval = null; |
|
|
|
|
1421
|
|
|
|
1422
|
|
|
|
1423
|
|
|
$retval = $validator->validate($this); |
1424
|
|
|
if (count($retval) > 0) { |
1425
|
|
|
$failureMap->addAll($retval); |
1426
|
|
|
} |
1427
|
|
|
|
1428
|
|
|
|
1429
|
|
|
$this->alreadyInValidation = false; |
1430
|
|
|
} |
1431
|
|
|
|
1432
|
|
|
$this->validationFailures = $failureMap; |
1433
|
|
|
|
1434
|
|
|
return (Boolean) (!(count($this->validationFailures) > 0)); |
1435
|
|
|
|
1436
|
|
|
} |
1437
|
|
|
|
1438
|
|
|
/** |
1439
|
|
|
* Gets any ConstraintViolation objects that resulted from last call to validate(). |
1440
|
|
|
* |
1441
|
|
|
* |
1442
|
|
|
* @return object ConstraintViolationList |
1443
|
|
|
* @see validate() |
1444
|
|
|
*/ |
1445
|
|
|
public function getValidationFailures() |
1446
|
|
|
{ |
1447
|
|
|
return $this->validationFailures; |
1448
|
|
|
} |
1449
|
|
|
|
1450
|
|
|
/** |
1451
|
|
|
* Code to be run before persisting the object |
1452
|
|
|
* @param ConnectionInterface $con |
1453
|
|
|
* @return boolean |
1454
|
|
|
*/ |
1455
|
|
|
public function preSave(ConnectionInterface $con = null) |
|
|
|
|
1456
|
|
|
{ |
1457
|
|
|
return true; |
1458
|
|
|
} |
1459
|
|
|
|
1460
|
|
|
/** |
1461
|
|
|
* Code to be run after persisting the object |
1462
|
|
|
* @param ConnectionInterface $con |
1463
|
|
|
*/ |
1464
|
|
|
public function postSave(ConnectionInterface $con = null) |
|
|
|
|
1465
|
|
|
{ |
1466
|
|
|
|
1467
|
|
|
} |
1468
|
|
|
|
1469
|
|
|
/** |
1470
|
|
|
* Code to be run before inserting to database |
1471
|
|
|
* @param ConnectionInterface $con |
1472
|
|
|
* @return boolean |
1473
|
|
|
*/ |
1474
|
|
|
public function preInsert(ConnectionInterface $con = null) |
|
|
|
|
1475
|
|
|
{ |
1476
|
|
|
return true; |
1477
|
|
|
} |
1478
|
|
|
|
1479
|
|
|
/** |
1480
|
|
|
* Code to be run after inserting to database |
1481
|
|
|
* @param ConnectionInterface $con |
1482
|
|
|
*/ |
1483
|
|
|
public function postInsert(ConnectionInterface $con = null) |
|
|
|
|
1484
|
|
|
{ |
1485
|
|
|
|
1486
|
|
|
} |
1487
|
|
|
|
1488
|
|
|
/** |
1489
|
|
|
* Code to be run before updating the object in database |
1490
|
|
|
* @param ConnectionInterface $con |
1491
|
|
|
* @return boolean |
1492
|
|
|
*/ |
1493
|
|
|
public function preUpdate(ConnectionInterface $con = null) |
|
|
|
|
1494
|
|
|
{ |
1495
|
|
|
return true; |
1496
|
|
|
} |
1497
|
|
|
|
1498
|
|
|
/** |
1499
|
|
|
* Code to be run after updating the object in database |
1500
|
|
|
* @param ConnectionInterface $con |
1501
|
|
|
*/ |
1502
|
|
|
public function postUpdate(ConnectionInterface $con = null) |
|
|
|
|
1503
|
|
|
{ |
1504
|
|
|
|
1505
|
|
|
} |
1506
|
|
|
|
1507
|
|
|
/** |
1508
|
|
|
* Code to be run before deleting the object in database |
1509
|
|
|
* @param ConnectionInterface $con |
1510
|
|
|
* @return boolean |
1511
|
|
|
*/ |
1512
|
|
|
public function preDelete(ConnectionInterface $con = null) |
|
|
|
|
1513
|
|
|
{ |
1514
|
|
|
return true; |
1515
|
|
|
} |
1516
|
|
|
|
1517
|
|
|
/** |
1518
|
|
|
* Code to be run after deleting the object in database |
1519
|
|
|
* @param ConnectionInterface $con |
1520
|
|
|
*/ |
1521
|
|
|
public function postDelete(ConnectionInterface $con = null) |
|
|
|
|
1522
|
|
|
{ |
1523
|
|
|
|
1524
|
|
|
} |
1525
|
|
|
|
1526
|
|
|
|
1527
|
|
|
/** |
1528
|
|
|
* Derived method to catches calls to undefined methods. |
1529
|
|
|
* |
1530
|
|
|
* Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
1531
|
|
|
* Allows to define default __call() behavior if you overwrite __call() |
1532
|
|
|
* |
1533
|
|
|
* @param string $name |
1534
|
|
|
* @param mixed $params |
1535
|
|
|
* |
1536
|
|
|
* @return array|string |
1537
|
|
|
*/ |
1538
|
|
View Code Duplication |
public function __call($name, $params) |
|
|
|
|
1539
|
|
|
{ |
1540
|
|
|
if (0 === strpos($name, 'get')) { |
1541
|
|
|
$virtualColumn = substr($name, 3); |
1542
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
1543
|
|
|
return $this->getVirtualColumn($virtualColumn); |
1544
|
|
|
} |
1545
|
|
|
|
1546
|
|
|
$virtualColumn = lcfirst($virtualColumn); |
1547
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
1548
|
|
|
return $this->getVirtualColumn($virtualColumn); |
1549
|
|
|
} |
1550
|
|
|
} |
1551
|
|
|
|
1552
|
|
|
if (0 === strpos($name, 'from')) { |
1553
|
|
|
$format = substr($name, 4); |
1554
|
|
|
|
1555
|
|
|
return $this->importFrom($format, reset($params)); |
|
|
|
|
1556
|
|
|
} |
1557
|
|
|
|
1558
|
|
|
if (0 === strpos($name, 'to')) { |
1559
|
|
|
$format = substr($name, 2); |
1560
|
|
|
$includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
1561
|
|
|
|
1562
|
|
|
return $this->exportTo($format, $includeLazyLoadColumns); |
1563
|
|
|
} |
1564
|
|
|
|
1565
|
|
|
throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
1566
|
|
|
} |
1567
|
|
|
|
1568
|
|
|
} |
1569
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.