Completed
Push — development ( cfd391...deed4d )
by Andrij
12:03
created

modules/xbanners/models/Base/BannerImageI18n.php (32 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace xbanners\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use CMSFactory\PropelBaseModelClass;
8
use Propel\Runtime\Propel;
9
use Propel\Runtime\ActiveQuery\Criteria;
10
use Propel\Runtime\ActiveQuery\ModelCriteria;
11
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
12
use Propel\Runtime\Collection\Collection;
13
use Propel\Runtime\Connection\ConnectionInterface;
14
use Propel\Runtime\Exception\BadMethodCallException;
15
use Propel\Runtime\Exception\LogicException;
16
use Propel\Runtime\Exception\PropelException;
17
use Propel\Runtime\Map\TableMap;
18
use Propel\Runtime\Parser\AbstractParser;
19
use xbanners\models\BannerImage as ChildBannerImage;
20
use xbanners\models\BannerImageI18nQuery as ChildBannerImageI18nQuery;
21
use xbanners\models\BannerImageQuery as ChildBannerImageQuery;
22
use xbanners\models\Map\BannerImageI18nTableMap;
23
24
/**
25
 * Base class that represents a row from the 'banner_image_i18n' table.
26
 *
27
 *
28
 *
29
 * @package    propel.generator.xbanners.models.Base
30
 */
31
abstract class BannerImageI18n extends PropelBaseModelClass implements ActiveRecordInterface
32
{
33
    /**
34
     * TableMap class name
35
     */
36
    const TABLE_MAP = '\\xbanners\\models\\Map\\BannerImageI18nTableMap';
37
38
39
    /**
40
     * attribute to determine if this object has previously been saved.
41
     * @var boolean
42
     */
43
    protected $new = true;
44
45
    /**
46
     * attribute to determine whether this object has been deleted.
47
     * @var boolean
48
     */
49
    protected $deleted = false;
50
51
    /**
52
     * The columns that have been modified in current object.
53
     * Tracking modified columns allows us to only update modified columns.
54
     * @var array
55
     */
56
    protected $modifiedColumns = array();
57
58
    /**
59
     * The (virtual) columns that are added at runtime
60
     * The formatters can add supplementary columns based on a resultset
61
     * @var array
62
     */
63
    protected $virtualColumns = array();
64
65
    /**
66
     * The value for the id field.
67
     *
68
     * @var        int
69
     */
70
    protected $id;
71
72
    /**
73
     * The value for the locale field.
74
     *
75
     * Note: this column has a database default value of: 'ru'
76
     * @var        string
77
     */
78
    protected $locale;
79
80
    /**
81
     * The value for the src field.
82
     *
83
     * @var        string
84
     */
85
    protected $src;
86
87
    /**
88
     * The value for the name field.
89
     *
90
     * @var        string
91
     */
92
    protected $name;
93
94
    /**
95
     * The value for the clicks field.
96
     *
97
     * @var        int
98
     */
99
    protected $clicks;
100
101
    /**
102
     * The value for the description field.
103
     *
104
     * @var        string
105
     */
106
    protected $description;
107
108
    /**
109
     * @var        ChildBannerImage
110
     */
111
    protected $aBannerImage;
112
113
    /**
114
     * Flag to prevent endless save loop, if this object is referenced
115
     * by another object which falls in this transaction.
116
     *
117
     * @var boolean
118
     */
119
    protected $alreadyInSave = false;
120
121
    /**
122
     * Applies default values to this object.
123
     * This method should be called from the object's constructor (or
124
     * equivalent initialization method).
125
     * @see __construct()
126
     */
127
    public function applyDefaultValues()
128
    {
129
        $this->locale = 'ru';
130
    }
131
132
    /**
133
     * Initializes internal state of xbanners\models\Base\BannerImageI18n object.
134
     * @see applyDefaults()
135
     */
136
    public function __construct()
137
    {
138
        $this->applyDefaultValues();
139
    }
140
141
    /**
142
     * Returns whether the object has been modified.
143
     *
144
     * @return boolean True if the object has been modified.
145
     */
146
    public function isModified()
147
    {
148
        return !!$this->modifiedColumns;
149
    }
150
151
    /**
152
     * Has specified column been modified?
153
     *
154
     * @param  string  $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
155
     * @return boolean True if $col has been modified.
156
     */
157
    public function isColumnModified($col)
158
    {
159
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
160
    }
161
162
    /**
163
     * Get the columns that have been modified in this object.
164
     * @return array A unique list of the modified column names for this object.
165
     */
166
    public function getModifiedColumns()
167
    {
168
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
169
    }
170
171
    /**
172
     * Returns whether the object has ever been saved.  This will
173
     * be false, if the object was retrieved from storage or was created
174
     * and then saved.
175
     *
176
     * @return boolean true, if the object has never been persisted.
177
     */
178
    public function isNew()
179
    {
180
        return $this->new;
181
    }
182
183
    /**
184
     * Setter for the isNew attribute.  This method will be called
185
     * by Propel-generated children and objects.
186
     *
187
     * @param boolean $b the state of the object.
188
     */
189
    public function setNew($b)
190
    {
191
        $this->new = (boolean) $b;
192
    }
193
194
    /**
195
     * Whether this object has been deleted.
196
     * @return boolean The deleted state of this object.
197
     */
198
    public function isDeleted()
199
    {
200
        return $this->deleted;
201
    }
202
203
    /**
204
     * Specify whether this object has been deleted.
205
     * @param  boolean $b The deleted state of this object.
206
     * @return void
207
     */
208
    public function setDeleted($b)
209
    {
210
        $this->deleted = (boolean) $b;
211
    }
212
213
    /**
214
     * Sets the modified state for the object to be false.
215
     * @param  string $col If supplied, only the specified column is reset.
216
     * @return void
217
     */
218 View Code Duplication
    public function resetModified($col = null)
219
    {
220
        if (null !== $col) {
221
            if (isset($this->modifiedColumns[$col])) {
222
                unset($this->modifiedColumns[$col]);
223
            }
224
        } else {
225
            $this->modifiedColumns = array();
226
        }
227
    }
228
229
    /**
230
     * Compares this with another <code>BannerImageI18n</code> instance.  If
231
     * <code>obj</code> is an instance of <code>BannerImageI18n</code>, delegates to
232
     * <code>equals(BannerImageI18n)</code>.  Otherwise, returns <code>false</code>.
233
     *
234
     * @param  mixed   $obj The object to compare to.
235
     * @return boolean Whether equal to the object specified.
236
     */
237 View Code Duplication
    public function equals($obj)
238
    {
239
        if (!$obj instanceof static) {
240
            return false;
241
        }
242
243
        if ($this === $obj) {
244
            return true;
245
        }
246
247
        if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) {
248
            return false;
249
        }
250
251
        return $this->getPrimaryKey() === $obj->getPrimaryKey();
252
    }
253
254
    /**
255
     * Get the associative array of the virtual columns in this object
256
     *
257
     * @return array
258
     */
259
    public function getVirtualColumns()
260
    {
261
        return $this->virtualColumns;
262
    }
263
264
    /**
265
     * Checks the existence of a virtual column in this object
266
     *
267
     * @param  string  $name The virtual column name
268
     * @return boolean
269
     */
270
    public function hasVirtualColumn($name)
271
    {
272
        return array_key_exists($name, $this->virtualColumns);
273
    }
274
275
    /**
276
     * Get the value of a virtual column in this object
277
     *
278
     * @param  string $name The virtual column name
279
     * @return mixed
280
     *
281
     * @throws PropelException
282
     */
283 View Code Duplication
    public function getVirtualColumn($name)
284
    {
285
        if (!$this->hasVirtualColumn($name)) {
286
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
287
        }
288
289
        return $this->virtualColumns[$name];
290
    }
291
292
    /**
293
     * Set the value of a virtual column in this object
294
     *
295
     * @param string $name  The virtual column name
296
     * @param mixed  $value The value to give to the virtual column
297
     *
298
     * @return $this|BannerImageI18n The current object, for fluid interface
299
     */
300
    public function setVirtualColumn($name, $value)
301
    {
302
        $this->virtualColumns[$name] = $value;
303
304
        return $this;
305
    }
306
307
    /**
308
     * Logs a message using Propel::log().
309
     *
310
     * @param  string  $msg
311
     * @param  int     $priority One of the Propel::LOG_* logging levels
312
     * @return boolean
313
     */
314
    protected function log($msg, $priority = Propel::LOG_INFO)
315
    {
316
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
317
    }
318
319
    /**
320
     * Export the current object properties to a string, using a given parser format
321
     * <code>
322
     * $book = BookQuery::create()->findPk(9012);
323
     * echo $book->exportTo('JSON');
324
     *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
325
     * </code>
326
     *
327
     * @param  mixed   $parser                 A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
328
     * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
329
     * @return string  The exported data
330
     */
331 View Code Duplication
    public function exportTo($parser, $includeLazyLoadColumns = true)
332
    {
333
        if (!$parser instanceof AbstractParser) {
334
            $parser = AbstractParser::getParser($parser);
335
        }
336
337
        return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
338
    }
339
340
    /**
341
     * Clean up internal collections prior to serializing
342
     * Avoids recursive loops that turn into segmentation faults when serializing
343
     */
344 View Code Duplication
    public function __sleep()
345
    {
346
        $this->clearAllReferences();
347
348
        $cls = new \ReflectionClass($this);
349
        $propertyNames = [];
350
        $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC));
351
352
        foreach($serializableProperties as $property) {
353
            $propertyNames[] = $property->getName();
354
        }
355
356
        return $propertyNames;
357
    }
358
359
    /**
360
     * Get the [id] column value.
361
     *
362
     * @return int
363
     */
364
    public function getId()
365
    {
366
        return $this->id;
367
    }
368
369
    /**
370
     * Get the [locale] column value.
371
     *
372
     * @return string
373
     */
374
    public function getLocale()
375
    {
376
        return $this->locale;
377
    }
378
379
    /**
380
     * Get the [src] column value.
381
     *
382
     * @return string
383
     */
384
    public function getSrc()
385
    {
386
        return $this->src;
387
    }
388
389
    /**
390
     * Get the [name] column value.
391
     *
392
     * @return string
393
     */
394
    public function getName()
395
    {
396
        return $this->name;
397
    }
398
399
    /**
400
     * Get the [clicks] column value.
401
     *
402
     * @return int
403
     */
404
    public function getClicks()
405
    {
406
        return $this->clicks;
407
    }
408
409
    /**
410
     * Get the [description] column value.
411
     *
412
     * @return string
413
     */
414
    public function getDescription()
415
    {
416
        return $this->description;
417
    }
418
419
    /**
420
     * Set the value of [id] column.
421
     *
422
     * @param int $v new value
423
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
424
     */
425 View Code Duplication
    public function setId($v)
426
    {
427
        if ($v !== null) {
428
            $v = (int) $v;
429
        }
430
431
        if ($this->id !== $v) {
432
            $this->id = $v;
433
            $this->modifiedColumns[BannerImageI18nTableMap::COL_ID] = true;
434
        }
435
436
        if ($this->aBannerImage !== null && $this->aBannerImage->getId() !== $v) {
437
            $this->aBannerImage = null;
438
        }
439
440
        return $this;
441
    } // setId()
442
443
    /**
444
     * Set the value of [locale] column.
445
     *
446
     * @param string $v new value
447
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
448
     */
449 View Code Duplication
    public function setLocale($v)
450
    {
451
        if ($v !== null) {
452
            $v = (string) $v;
453
        }
454
455
        if ($this->locale !== $v) {
456
            $this->locale = $v;
457
            $this->modifiedColumns[BannerImageI18nTableMap::COL_LOCALE] = true;
458
        }
459
460
        return $this;
461
    } // setLocale()
462
463
    /**
464
     * Set the value of [src] column.
465
     *
466
     * @param string $v new value
467
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
468
     */
469 View Code Duplication
    public function setSrc($v)
470
    {
471
        if ($v !== null) {
472
            $v = (string) $v;
473
        }
474
475
        if ($this->src !== $v) {
476
            $this->src = $v;
477
            $this->modifiedColumns[BannerImageI18nTableMap::COL_SRC] = true;
478
        }
479
480
        return $this;
481
    } // setSrc()
482
483
    /**
484
     * Set the value of [name] column.
485
     *
486
     * @param string $v new value
487
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
488
     */
489 View Code Duplication
    public function setName($v)
490
    {
491
        if ($v !== null) {
492
            $v = (string) $v;
493
        }
494
495
        if ($this->name !== $v) {
496
            $this->name = $v;
497
            $this->modifiedColumns[BannerImageI18nTableMap::COL_NAME] = true;
498
        }
499
500
        return $this;
501
    } // setName()
502
503
    /**
504
     * Set the value of [clicks] column.
505
     *
506
     * @param int $v new value
507
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
508
     */
509 View Code Duplication
    public function setClicks($v)
510
    {
511
        if ($v !== null) {
512
            $v = (int) $v;
513
        }
514
515
        if ($this->clicks !== $v) {
516
            $this->clicks = $v;
517
            $this->modifiedColumns[BannerImageI18nTableMap::COL_CLICKS] = true;
518
        }
519
520
        return $this;
521
    } // setClicks()
522
523
    /**
524
     * Set the value of [description] column.
525
     *
526
     * @param string $v new value
527
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
528
     */
529 View Code Duplication
    public function setDescription($v)
530
    {
531
        if ($v !== null) {
532
            $v = (string) $v;
533
        }
534
535
        if ($this->description !== $v) {
536
            $this->description = $v;
537
            $this->modifiedColumns[BannerImageI18nTableMap::COL_DESCRIPTION] = true;
538
        }
539
540
        return $this;
541
    } // setDescription()
542
543
    /**
544
     * Indicates whether the columns in this object are only set to default values.
545
     *
546
     * This method can be used in conjunction with isModified() to indicate whether an object is both
547
     * modified _and_ has some values set which are non-default.
548
     *
549
     * @return boolean Whether the columns in this object are only been set with default values.
550
     */
551
    public function hasOnlyDefaultValues()
552
    {
553
            if ($this->locale !== 'ru') {
554
                return false;
555
            }
556
557
        // otherwise, everything was equal, so return TRUE
558
        return true;
559
    } // hasOnlyDefaultValues()
560
561
    /**
562
     * Hydrates (populates) the object variables with values from the database resultset.
563
     *
564
     * An offset (0-based "start column") is specified so that objects can be hydrated
565
     * with a subset of the columns in the resultset rows.  This is needed, for example,
566
     * for results of JOIN queries where the resultset row includes columns from two or
567
     * more tables.
568
     *
569
     * @param array   $row       The row returned by DataFetcher->fetch().
570
     * @param int     $startcol  0-based offset column which indicates which restultset column to start with.
571
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
572
     * @param string  $indexType The index type of $row. Mostly DataFetcher->getIndexType().
573
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
574
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
575
     *
576
     * @return int             next starting column
577
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
578
     */
579 View Code Duplication
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
580
    {
581
        try {
582
583
            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : BannerImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
584
            $this->id = (null !== $col) ? (int) $col : null;
585
586
            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : BannerImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
587
            $this->locale = (null !== $col) ? (string) $col : null;
588
589
            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : BannerImageI18nTableMap::translateFieldName('Src', TableMap::TYPE_PHPNAME, $indexType)];
590
            $this->src = (null !== $col) ? (string) $col : null;
591
592
            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : BannerImageI18nTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
593
            $this->name = (null !== $col) ? (string) $col : null;
594
595
            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : BannerImageI18nTableMap::translateFieldName('Clicks', TableMap::TYPE_PHPNAME, $indexType)];
596
            $this->clicks = (null !== $col) ? (int) $col : null;
597
598
            $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : BannerImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
599
            $this->description = (null !== $col) ? (string) $col : null;
600
            $this->resetModified();
601
602
            $this->setNew(false);
603
604
            if ($rehydrate) {
605
                $this->ensureConsistency();
606
            }
607
608
            return $startcol + 6; // 6 = BannerImageI18nTableMap::NUM_HYDRATE_COLUMNS.
609
610
        } catch (Exception $e) {
611
            throw new PropelException(sprintf('Error populating %s object', '\\xbanners\\models\\BannerImageI18n'), 0, $e);
612
        }
613
    }
614
615
    /**
616
     * Checks and repairs the internal consistency of the object.
617
     *
618
     * This method is executed after an already-instantiated object is re-hydrated
619
     * from the database.  It exists to check any foreign keys to make sure that
620
     * the objects related to the current object are correct based on foreign key.
621
     *
622
     * You can override this method in the stub class, but you should always invoke
623
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
624
     * in case your model changes.
625
     *
626
     * @throws PropelException
627
     */
628
    public function ensureConsistency()
629
    {
630
        if ($this->aBannerImage !== null && $this->id !== $this->aBannerImage->getId()) {
631
            $this->aBannerImage = null;
632
        }
633
    } // ensureConsistency
634
635
    /**
636
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
637
     *
638
     * This will only work if the object has been saved and has a valid primary key set.
639
     *
640
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
641
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
642
     * @return void
643
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
644
     */
645 View Code Duplication
    public function reload($deep = false, ConnectionInterface $con = null)
646
    {
647
        if ($this->isDeleted()) {
648
            throw new PropelException("Cannot reload a deleted object.");
649
        }
650
651
        if ($this->isNew()) {
652
            throw new PropelException("Cannot reload an unsaved object.");
653
        }
654
655
        if ($con === null) {
656
            $con = Propel::getServiceContainer()->getReadConnection(BannerImageI18nTableMap::DATABASE_NAME);
657
        }
658
659
        // We don't need to alter the object instance pool; we're just modifying this instance
660
        // already in the pool.
661
662
        $dataFetcher = ChildBannerImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
663
        $row = $dataFetcher->fetch();
664
        $dataFetcher->close();
665
        if (!$row) {
666
            throw new PropelException('Cannot find matching row in the database to reload object values.');
667
        }
668
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
669
670
        if ($deep) {  // also de-associate any related objects?
671
672
            $this->aBannerImage = null;
673
        } // if (deep)
674
    }
675
676
    /**
677
     * Removes this object from datastore and sets delete attribute.
678
     *
679
     * @param      ConnectionInterface $con
680
     * @return void
681
     * @throws PropelException
682
     * @see BannerImageI18n::setDeleted()
683
     * @see BannerImageI18n::isDeleted()
684
     */
685 View Code Duplication
    public function delete(ConnectionInterface $con = null)
686
    {
687
        if ($this->isDeleted()) {
688
            throw new PropelException("This object has already been deleted.");
689
        }
690
691
        if ($con === null) {
692
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
693
        }
694
695
        $con->transaction(function () use ($con) {
696
            $deleteQuery = ChildBannerImageI18nQuery::create()
697
                ->filterByPrimaryKey($this->getPrimaryKey());
698
            $ret = $this->preDelete($con);
699
            if ($ret) {
700
                $deleteQuery->delete($con);
701
                $this->postDelete($con);
702
                $this->setDeleted(true);
703
            }
704
        });
705
    }
706
707
    /**
708
     * Persists this object to the database.
709
     *
710
     * If the object is new, it inserts it; otherwise an update is performed.
711
     * All modified related objects will also be persisted in the doSave()
712
     * method.  This method wraps all precipitate database operations in a
713
     * single transaction.
714
     *
715
     * @param      ConnectionInterface $con
716
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
717
     * @throws PropelException
718
     * @see doSave()
719
     */
720 View Code Duplication
    public function save(ConnectionInterface $con = null)
721
    {
722
        if ($this->isDeleted()) {
723
            throw new PropelException("You cannot save an object that has been deleted.");
724
        }
725
726
        if ($con === null) {
727
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
728
        }
729
730
        return $con->transaction(function () use ($con) {
731
            $ret = $this->preSave($con);
732
            $isInsert = $this->isNew();
733
            if ($isInsert) {
734
                $ret = $ret && $this->preInsert($con);
735
            } else {
736
                $ret = $ret && $this->preUpdate($con);
737
            }
738
            if ($ret) {
739
                $affectedRows = $this->doSave($con);
740
                if ($isInsert) {
741
                    $this->postInsert($con);
742
                } else {
743
                    $this->postUpdate($con);
744
                }
745
                $this->postSave($con);
746
                BannerImageI18nTableMap::addInstanceToPool($this);
747
            } else {
748
                $affectedRows = 0;
749
            }
750
751
            return $affectedRows;
752
        });
753
    }
754
755
    /**
756
     * Performs the work of inserting or updating the row in the database.
757
     *
758
     * If the object is new, it inserts it; otherwise an update is performed.
759
     * All related objects are also updated in this method.
760
     *
761
     * @param      ConnectionInterface $con
762
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
763
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
764
     * @see save()
765
     */
766 View Code Duplication
    protected function doSave(ConnectionInterface $con)
767
    {
768
        $affectedRows = 0; // initialize var to track total num of affected rows
769
        if (!$this->alreadyInSave) {
770
            $this->alreadyInSave = true;
771
772
            // We call the save method on the following object(s) if they
773
            // were passed to this object by their corresponding set
774
            // method.  This object relates to these object(s) by a
775
            // foreign key reference.
776
777
            if ($this->aBannerImage !== null) {
778
                if ($this->aBannerImage->isModified() || $this->aBannerImage->isNew()) {
779
                    $affectedRows += $this->aBannerImage->save($con);
780
                }
781
                $this->setBannerImage($this->aBannerImage);
782
            }
783
784
            if ($this->isNew() || $this->isModified()) {
785
                // persist changes
786
                if ($this->isNew()) {
787
                    $this->doInsert($con);
788
                    $affectedRows += 1;
789
                } else {
790
                    $affectedRows += $this->doUpdate($con);
791
                }
792
                $this->resetModified();
793
            }
794
795
            $this->alreadyInSave = false;
796
797
        }
798
799
        return $affectedRows;
800
    } // doSave()
801
802
    /**
803
     * Insert the row in the database.
804
     *
805
     * @param      ConnectionInterface $con
806
     *
807
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
808
     * @see doSave()
809
     */
810
    protected function doInsert(ConnectionInterface $con)
811
    {
812
        $modifiedColumns = array();
813
        $index = 0;
814
815
816
         // check the columns in natural order for more readable SQL queries
817
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_ID)) {
818
            $modifiedColumns[':p' . $index++]  = 'id';
819
        }
820
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_LOCALE)) {
821
            $modifiedColumns[':p' . $index++]  = 'locale';
822
        }
823
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_SRC)) {
824
            $modifiedColumns[':p' . $index++]  = 'src';
825
        }
826
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_NAME)) {
827
            $modifiedColumns[':p' . $index++]  = 'name';
828
        }
829
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_CLICKS)) {
830
            $modifiedColumns[':p' . $index++]  = 'clicks';
831
        }
832
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_DESCRIPTION)) {
833
            $modifiedColumns[':p' . $index++]  = 'description';
834
        }
835
836
        $sql = sprintf(
837
            'INSERT INTO banner_image_i18n (%s) VALUES (%s)',
838
            implode(', ', $modifiedColumns),
839
            implode(', ', array_keys($modifiedColumns))
840
        );
841
842
        try {
843
            $stmt = $con->prepare($sql);
844
            foreach ($modifiedColumns as $identifier => $columnName) {
845
                switch ($columnName) {
846
                    case 'id':
847
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
848
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
849
                    case 'locale':
850
                        $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
851
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
852
                    case 'src':
853
                        $stmt->bindValue($identifier, $this->src, PDO::PARAM_STR);
854
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
855
                    case 'name':
856
                        $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
857
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
858
                    case 'clicks':
859
                        $stmt->bindValue($identifier, $this->clicks, PDO::PARAM_INT);
860
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
861
                    case 'description':
862
                        $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
863
                        break;
864
                }
865
            }
866
            $stmt->execute();
867
        } catch (Exception $e) {
868
            Propel::log($e->getMessage(), Propel::LOG_ERR);
869
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
870
        }
871
872
        $this->setNew(false);
873
    }
874
875
    /**
876
     * Update the row in the database.
877
     *
878
     * @param      ConnectionInterface $con
879
     *
880
     * @return Integer Number of updated rows
881
     * @see doSave()
882
     */
883
    protected function doUpdate(ConnectionInterface $con)
884
    {
885
        $selectCriteria = $this->buildPkeyCriteria();
886
        $valuesCriteria = $this->buildCriteria();
887
888
        return $selectCriteria->doUpdate($valuesCriteria, $con);
889
    }
890
891
    /**
892
     * Retrieves a field from the object by name passed in as a string.
893
     *
894
     * @param      string $name name
895
     * @param      string $type The type of fieldname the $name is of:
896
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
897
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
898
     *                     Defaults to TableMap::TYPE_PHPNAME.
899
     * @return mixed Value of field.
900
     */
901 View Code Duplication
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
902
    {
903
        $pos = BannerImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
904
        $field = $this->getByPosition($pos);
905
906
        return $field;
907
    }
908
909
    /**
910
     * Retrieves a field from the object by Position as specified in the xml schema.
911
     * Zero-based.
912
     *
913
     * @param      int $pos position in xml schema
914
     * @return mixed Value of field at $pos
915
     */
916
    public function getByPosition($pos)
917
    {
918
        switch ($pos) {
919
            case 0:
920
                return $this->getId();
921
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
922
            case 1:
923
                return $this->getLocale();
924
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
925
            case 2:
926
                return $this->getSrc();
927
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
928
            case 3:
929
                return $this->getName();
930
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
931
            case 4:
932
                return $this->getClicks();
933
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
934
            case 5:
935
                return $this->getDescription();
936
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
937
            default:
938
                return null;
939
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
940
        } // switch()
941
    }
942
943
    /**
944
     * Exports the object as an array.
945
     *
946
     * You can specify the key type of the array by passing one of the class
947
     * type constants.
948
     *
949
     * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
950
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
951
     *                    Defaults to TableMap::TYPE_PHPNAME.
952
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
953
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
954
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
955
     *
956
     * @return array an associative array containing the field names (as keys) and field values
957
     */
958
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
959
    {
960
961
        if (isset($alreadyDumpedObjects['BannerImageI18n'][$this->hashCode()])) {
962
            return '*RECURSION*';
963
        }
964
        $alreadyDumpedObjects['BannerImageI18n'][$this->hashCode()] = true;
965
        $keys = BannerImageI18nTableMap::getFieldNames($keyType);
966
        $result = array(
967
            $keys[0] => $this->getId(),
968
            $keys[1] => $this->getLocale(),
969
            $keys[2] => $this->getSrc(),
970
            $keys[3] => $this->getName(),
971
            $keys[4] => $this->getClicks(),
972
            $keys[5] => $this->getDescription(),
973
        );
974
        $virtualColumns = $this->virtualColumns;
975
        foreach ($virtualColumns as $key => $virtualColumn) {
976
            $result[$key] = $virtualColumn;
977
        }
978
979
        if ($includeForeignObjects) {
980
            if (null !== $this->aBannerImage) {
981
982
                switch ($keyType) {
983
                    case TableMap::TYPE_CAMELNAME:
984
                        $key = 'bannerImage';
985
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
986
                    case TableMap::TYPE_FIELDNAME:
987
                        $key = 'banner_image';
988
                        break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
989
                    default:
990
                        $key = 'BannerImage';
991
                }
992
993
                $result[$key] = $this->aBannerImage->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
994
            }
995
        }
996
997
        return $result;
998
    }
999
1000
    /**
1001
     * Sets a field from the object by name passed in as a string.
1002
     *
1003
     * @param  string $name
1004
     * @param  mixed  $value field value
1005
     * @param  string $type The type of fieldname the $name is of:
1006
     *                one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1007
     *                TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1008
     *                Defaults to TableMap::TYPE_PHPNAME.
1009
     * @return $this|\xbanners\models\BannerImageI18n
0 ignored issues
show
@return data type must not contain "$"
Loading history...
1010
     */
1011
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
1012
    {
1013
        $pos = BannerImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1014
1015
        return $this->setByPosition($pos, $value);
1016
    }
1017
1018
    /**
1019
     * Sets a field from the object by Position as specified in the xml schema.
1020
     * Zero-based.
1021
     *
1022
     * @param  int $pos position in xml schema
1023
     * @param  mixed $value field value
1024
     * @return $this|\xbanners\models\BannerImageI18n
0 ignored issues
show
@return data type must not contain "$"
Loading history...
1025
     */
1026
    public function setByPosition($pos, $value)
1027
    {
1028
        switch ($pos) {
1029
            case 0:
1030
                $this->setId($value);
1031
                break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
1032
            case 1:
1033
                $this->setLocale($value);
1034
                break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
1035
            case 2:
1036
                $this->setSrc($value);
1037
                break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
1038
            case 3:
1039
                $this->setName($value);
1040
                break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
1041
            case 4:
1042
                $this->setClicks($value);
1043
                break;
0 ignored issues
show
Case breaking statements must be followed by a single blank line
Loading history...
1044
            case 5:
1045
                $this->setDescription($value);
1046
                break;
1047
        } // switch()
1048
1049
        return $this;
1050
    }
1051
1052
    /**
1053
     * Populates the object using an array.
1054
     *
1055
     * This is particularly useful when populating an object from one of the
1056
     * request arrays (e.g. $_POST).  This method goes through the column
1057
     * names, checking to see whether a matching key exists in populated
1058
     * array. If so the setByName() method is called for that column.
1059
     *
1060
     * You can specify the key type of the array by additionally passing one
1061
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1062
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1063
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1064
     *
1065
     * @param      array  $arr     An array to populate the object from.
1066
     * @param      string $keyType The type of keys the array uses.
1067
     * @return void
0 ignored issues
show
If there is no return value for a function, there must not be a @return tag.
Loading history...
1068
     */
1069 View Code Duplication
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
1070
    {
1071
        $keys = BannerImageI18nTableMap::getFieldNames($keyType);
1072
1073
        if (array_key_exists($keys[0], $arr)) {
1074
            $this->setId($arr[$keys[0]]);
1075
        }
1076
        if (array_key_exists($keys[1], $arr)) {
1077
            $this->setLocale($arr[$keys[1]]);
1078
        }
1079
        if (array_key_exists($keys[2], $arr)) {
1080
            $this->setSrc($arr[$keys[2]]);
1081
        }
1082
        if (array_key_exists($keys[3], $arr)) {
1083
            $this->setName($arr[$keys[3]]);
1084
        }
1085
        if (array_key_exists($keys[4], $arr)) {
1086
            $this->setClicks($arr[$keys[4]]);
1087
        }
1088
        if (array_key_exists($keys[5], $arr)) {
1089
            $this->setDescription($arr[$keys[5]]);
1090
        }
1091
    }
1092
1093
     /**
1094
     * Populate the current object from a string, using a given parser format
1095
     * <code>
1096
     * $book = new Book();
1097
     * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
1098
     * </code>
1099
     *
0 ignored issues
show
Expected 6 space(s) before asterisk; 5 found
Loading history...
1100
     * You can specify the key type of the array by additionally passing one
1101
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1102
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1103
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1104
     *
0 ignored issues
show
Expected 6 space(s) before asterisk; 5 found
Loading history...
1105
     * @param mixed $parser A AbstractParser instance,
1106
     *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
1107
     * @param string $data The source data to import from
1108
     * @param string $keyType The type of keys the array uses.
1109
     *
0 ignored issues
show
Expected 6 space(s) before asterisk; 5 found
Loading history...
1110
     * @return $this|\xbanners\models\BannerImageI18n The current object, for fluid interface
1111
     */
1112 View Code Duplication
    public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
1113
    {
1114
        if (!$parser instanceof AbstractParser) {
1115
            $parser = AbstractParser::getParser($parser);
1116
        }
1117
1118
        $this->fromArray($parser->toArray($data), $keyType);
1119
1120
        return $this;
1121
    }
1122
1123
    /**
1124
     * Build a Criteria object containing the values of all modified columns in this object.
1125
     *
1126
     * @return Criteria The Criteria object containing all modified values.
1127
     */
1128
    public function buildCriteria()
1129
    {
1130
        $criteria = new Criteria(BannerImageI18nTableMap::DATABASE_NAME);
1131
1132
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_ID)) {
1133
            $criteria->add(BannerImageI18nTableMap::COL_ID, $this->id);
1134
        }
1135
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_LOCALE)) {
1136
            $criteria->add(BannerImageI18nTableMap::COL_LOCALE, $this->locale);
1137
        }
1138
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_SRC)) {
1139
            $criteria->add(BannerImageI18nTableMap::COL_SRC, $this->src);
1140
        }
1141
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_NAME)) {
1142
            $criteria->add(BannerImageI18nTableMap::COL_NAME, $this->name);
1143
        }
1144
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_CLICKS)) {
1145
            $criteria->add(BannerImageI18nTableMap::COL_CLICKS, $this->clicks);
1146
        }
1147
        if ($this->isColumnModified(BannerImageI18nTableMap::COL_DESCRIPTION)) {
1148
            $criteria->add(BannerImageI18nTableMap::COL_DESCRIPTION, $this->description);
1149
        }
1150
1151
        return $criteria;
1152
    }
1153
1154
    /**
1155
     * Builds a Criteria object containing the primary key for this object.
1156
     *
1157
     * Unlike buildCriteria() this method includes the primary key values regardless
1158
     * of whether or not they have been modified.
1159
     *
1160
     * @throws LogicException if no primary key is defined
1161
     *
1162
     * @return Criteria The Criteria object containing value(s) for primary key(s).
1163
     */
1164
    public function buildPkeyCriteria()
1165
    {
1166
        $criteria = ChildBannerImageI18nQuery::create();
1167
        $criteria->add(BannerImageI18nTableMap::COL_ID, $this->id);
1168
        $criteria->add(BannerImageI18nTableMap::COL_LOCALE, $this->locale);
1169
1170
        return $criteria;
1171
    }
1172
1173
    /**
1174
     * If the primary key is not null, return the hashcode of the
1175
     * primary key. Otherwise, return the hash code of the object.
1176
     *
1177
     * @return int Hashcode
1178
     */
1179 View Code Duplication
    public function hashCode()
1180
    {
1181
        $validPk = null !== $this->getId() &&
1182
            null !== $this->getLocale();
1183
1184
        $validPrimaryKeyFKs = 1;
1185
        $primaryKeyFKs = [];
1186
1187
        //relation banner_image_i18n_fk_03c8df to table banner_image
1188
        if ($this->aBannerImage && $hash = spl_object_hash($this->aBannerImage)) {
1189
            $primaryKeyFKs[] = $hash;
1190
        } else {
1191
            $validPrimaryKeyFKs = false;
1192
        }
1193
1194
        if ($validPk) {
1195
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
1196
        } elseif ($validPrimaryKeyFKs) {
1197
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
1198
        }
1199
1200
        return spl_object_hash($this);
1201
    }
1202
1203
    /**
1204
     * Returns the composite primary key for this object.
1205
     * The array elements will be in same order as specified in XML.
1206
     * @return array
1207
     */
1208 View Code Duplication
    public function getPrimaryKey()
1209
    {
1210
        $pks = array();
1211
        $pks[0] = $this->getId();
1212
        $pks[1] = $this->getLocale();
1213
1214
        return $pks;
1215
    }
1216
1217
    /**
1218
     * Set the [composite] primary key.
1219
     *
1220
     * @param      array $keys The elements of the composite key (order must match the order in XML file).
1221
     * @return void
0 ignored issues
show
If there is no return value for a function, there must not be a @return tag.
Loading history...
1222
     */
1223
    public function setPrimaryKey($keys)
1224
    {
1225
        $this->setId($keys[0]);
1226
        $this->setLocale($keys[1]);
1227
    }
1228
1229
    /**
1230
     * Returns true if the primary key for this object is null.
1231
     * @return boolean
1232
     */
1233
    public function isPrimaryKeyNull()
1234
    {
1235
        return (null === $this->getId()) && (null === $this->getLocale());
1236
    }
1237
1238
    /**
1239
     * Sets contents of passed object to values from current object.
1240
     *
1241
     * If desired, this method can also make copies of all associated (fkey referrers)
1242
     * objects.
1243
     *
1244
     * @param      object $copyObj An object of \xbanners\models\BannerImageI18n (or compatible) type.
1245
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1246
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1247
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1248
     */
1249
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1250
    {
1251
        $copyObj->setId($this->getId());
1252
        $copyObj->setLocale($this->getLocale());
1253
        $copyObj->setSrc($this->getSrc());
1254
        $copyObj->setName($this->getName());
1255
        $copyObj->setClicks($this->getClicks());
1256
        $copyObj->setDescription($this->getDescription());
1257
        if ($makeNew) {
1258
            $copyObj->setNew(true);
1259
        }
1260
    }
1261
1262
    /**
1263
     * Makes a copy of this object that will be inserted as a new row in table when saved.
1264
     * It creates a new object filling in the simple attributes, but skipping any primary
1265
     * keys that are defined for the table.
1266
     *
1267
     * If desired, this method can also make copies of all associated (fkey referrers)
1268
     * objects.
1269
     *
1270
     * @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1271
     * @return \xbanners\models\BannerImageI18n Clone of current object.
1272
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1273
     */
1274 View Code Duplication
    public function copy($deepCopy = false)
1275
    {
1276
        // we use get_class(), because this might be a subclass
1277
        $clazz = get_class($this);
1278
        $copyObj = new $clazz();
1279
        $this->copyInto($copyObj, $deepCopy);
1280
1281
        return $copyObj;
1282
    }
1283
1284
    /**
1285
     * Declares an association between this object and a ChildBannerImage object.
1286
     *
1287
     * @param  ChildBannerImage $v
1288
     * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
1289
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1290
     */
1291 View Code Duplication
    public function setBannerImage(ChildBannerImage $v = null)
1292
    {
1293
        if ($v === null) {
1294
            $this->setId(NULL);
1295
        } else {
1296
            $this->setId($v->getId());
1297
        }
1298
1299
        $this->aBannerImage = $v;
1300
1301
        // Add binding for other direction of this n:n relationship.
1302
        // If this object has already been added to the ChildBannerImage object, it will not be re-added.
1303
        if ($v !== null) {
1304
            $v->addBannerImageI18n($this);
1305
        }
1306
1307
1308
        return $this;
1309
    }
1310
1311
1312
    /**
1313
     * Get the associated ChildBannerImage object
1314
     *
1315
     * @param  ConnectionInterface $con Optional Connection object.
1316
     * @return ChildBannerImage The associated ChildBannerImage object.
1317
     * @throws PropelException
0 ignored issues
show
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1318
     */
1319
    public function getBannerImage(ConnectionInterface $con = null)
1320
    {
1321
        if ($this->aBannerImage === null && ($this->id !== null)) {
1322
            $this->aBannerImage = ChildBannerImageQuery::create()->findPk($this->id, $con);
1323
            /* The following can be used additionally to
1324
                guarantee the related object contains a reference
1325
                to this object.  This level of coupling may, however, be
1326
                undesirable since it could result in an only partially populated collection
1327
                in the referenced object.
1328
                $this->aBannerImage->addBannerImageI18ns($this);
1329
             */
1330
        }
1331
1332
        return $this->aBannerImage;
1333
    }
1334
1335
    /**
1336
     * Clears the current object, sets all attributes to their default values and removes
1337
     * outgoing references as well as back-references (from other objects to this one. Results probably in a database
1338
     * change of those foreign objects when you call `save` there).
1339
     */
1340
    public function clear()
1341
    {
1342
        if (null !== $this->aBannerImage) {
1343
            $this->aBannerImage->removeBannerImageI18n($this);
1344
        }
1345
        $this->id = null;
1346
        $this->locale = null;
1347
        $this->src = null;
1348
        $this->name = null;
1349
        $this->clicks = null;
1350
        $this->description = null;
1351
        $this->alreadyInSave = false;
1352
        $this->clearAllReferences();
1353
        $this->applyDefaultValues();
1354
        $this->resetModified();
1355
        $this->setNew(true);
1356
        $this->setDeleted(false);
1357
    }
1358
1359
    /**
1360
     * Resets all references and back-references to other model objects or collections of model objects.
1361
     *
1362
     * This method is used to reset all php object references (not the actual reference in the database).
1363
     * Necessary for object serialisation.
1364
     *
1365
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
1366
     */
1367
    public function clearAllReferences($deep = false)
1368
    {
1369
        if ($deep) {
1370
        } // if ($deep)
1371
1372
        $this->aBannerImage = null;
1373
    }
1374
1375
    /**
1376
     * Return the string representation of this object
1377
     *
1378
     * @return string
1379
     */
1380
    public function __toString()
1381
    {
1382
        return (string) $this->exportTo(BannerImageI18nTableMap::DEFAULT_STRING_FORMAT);
1383
    }
1384
1385
    /**
1386
     * Code to be run before persisting the object
1387
     * @param  ConnectionInterface $con
1388
     * @return boolean
1389
     */
1390
    public function preSave(ConnectionInterface $con = null)
1391
    {
1392
        if (is_callable('parent::preSave')) {
1393
            return parent::preSave($con);
1394
        }
1395
        return true;
1396
    }
1397
1398
    /**
1399
     * Code to be run after persisting the object
1400
     * @param ConnectionInterface $con
1401
     */
1402
    public function postSave(ConnectionInterface $con = null)
1403
    {
1404
        if (is_callable('parent::postSave')) {
1405
            parent::postSave($con);
1406
        }
1407
    }
1408
1409
    /**
1410
     * Code to be run before inserting to database
1411
     * @param  ConnectionInterface $con
1412
     * @return boolean
1413
     */
1414
    public function preInsert(ConnectionInterface $con = null)
1415
    {
1416
        if (is_callable('parent::preInsert')) {
1417
            return parent::preInsert($con);
1418
        }
1419
        return true;
1420
    }
1421
1422
    /**
1423
     * Code to be run after inserting to database
1424
     * @param ConnectionInterface $con
1425
     */
1426
    public function postInsert(ConnectionInterface $con = null)
1427
    {
1428
        if (is_callable('parent::postInsert')) {
1429
            parent::postInsert($con);
1430
        }
1431
    }
1432
1433
    /**
1434
     * Code to be run before updating the object in database
1435
     * @param  ConnectionInterface $con
1436
     * @return boolean
1437
     */
1438
    public function preUpdate(ConnectionInterface $con = null)
1439
    {
1440
        if (is_callable('parent::preUpdate')) {
1441
            return parent::preUpdate($con);
1442
        }
1443
        return true;
1444
    }
1445
1446
    /**
1447
     * Code to be run after updating the object in database
1448
     * @param ConnectionInterface $con
1449
     */
1450
    public function postUpdate(ConnectionInterface $con = null)
1451
    {
1452
        if (is_callable('parent::postUpdate')) {
1453
            parent::postUpdate($con);
1454
        }
1455
    }
1456
1457
    /**
1458
     * Code to be run before deleting the object in database
1459
     * @param  ConnectionInterface $con
1460
     * @return boolean
1461
     */
1462
    public function preDelete(ConnectionInterface $con = null)
1463
    {
1464
        if (is_callable('parent::preDelete')) {
1465
            return parent::preDelete($con);
1466
        }
1467
        return true;
1468
    }
1469
1470
    /**
1471
     * Code to be run after deleting the object in database
1472
     * @param ConnectionInterface $con
1473
     */
1474
    public function postDelete(ConnectionInterface $con = null)
1475
    {
1476
        if (is_callable('parent::postDelete')) {
1477
            parent::postDelete($con);
1478
        }
1479
    }
1480
1481
1482
    /**
1483
     * Derived method to catches calls to undefined methods.
1484
     *
1485
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
1486
     * Allows to define default __call() behavior if you overwrite __call()
1487
     *
1488
     * @param string $name
1489
     * @param mixed  $params
1490
     *
1491
     * @return array|string
1492
     */
1493 View Code Duplication
    public function __call($name, $params)
1494
    {
1495
        if (0 === strpos($name, 'get')) {
1496
            $virtualColumn = substr($name, 3);
1497
            if ($this->hasVirtualColumn($virtualColumn)) {
1498
                return $this->getVirtualColumn($virtualColumn);
1499
            }
1500
1501
            $virtualColumn = lcfirst($virtualColumn);
1502
            if ($this->hasVirtualColumn($virtualColumn)) {
1503
                return $this->getVirtualColumn($virtualColumn);
1504
            }
1505
        }
1506
1507
        if (0 === strpos($name, 'from')) {
1508
            $format = substr($name, 4);
1509
1510
            return $this->importFrom($format, reset($params));
1511
        }
1512
1513
        if (0 === strpos($name, 'to')) {
1514
            $format = substr($name, 2);
1515
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
1516
1517
            return $this->exportTo($format, $includeLazyLoadColumns);
1518
        }
1519
1520
        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
1521
    }
1522
1523
}
1524