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