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