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