       1: <?php
       2:
       3: namespace Thelia\Model\om;
       4:
       5: use \BaseObject;
       6: use \BasePeer;
       7: use \Criteria;
       8: use \DateTime;
       9: use \Exception;
      10: use \PDO;
      11: use \Persistent;
      12: use \Propel;
      13: use \PropelCollection;
      14: use \PropelDateTime;
      15: use \PropelException;
      16: use \PropelObjectCollection;
      17: use \PropelPDO;
      18: use Thelia\Model\Config;
      19: use Thelia\Model\ConfigI18n;
      20: use Thelia\Model\ConfigI18nQuery;
      21: use Thelia\Model\ConfigPeer;
      22: use Thelia\Model\ConfigQuery;
      23:
      24: /**
      25:  * Base class that represents a row from the 'config' table.
      26:  *
      27:  *
      28:  *
      29:  * @package    propel.generator.Thelia.Model.om
      30:  */
      31: abstract class BaseConfig extends BaseObject implements Persistent
      32: {
      33:     /**
      34:      * Peer class name
      35:      */
      36:     const PEER = 'Thelia\\Model\\ConfigPeer';
      37:
      38:     /**
      39:      * The Peer class.
      40:      * Instance provides a convenient way of calling static methods on a class
      41:      * that calling code may not be able to identify.
      42:      * @var        ConfigPeer
      43:      */
      44:     protected static $peer;
      45:
      46:     /**
      47:      * The flag var to prevent infinit loop in deep copy
      48:      * @var       boolean
      49:      */
      50:     protected $startCopy = false;
      51:
      52:     /**
      53:      * The value for the id field.
      54:      * @var        int
      55:      */
      56:     protected $id;
      57:
      58:     /**
      59:      * The value for the name field.
      60:      * @var        string
      61:      */
      62:     protected $name;
      63:
      64:     /**
      65:      * The value for the value field.
      66:      * @var        string
      67:      */
      68:     protected $value;
      69:
      70:     /**
      71:      * The value for the secured field.
      72:      * Note: this column has a database default value of: 1
      73:      * @var        int
      74:      */
      75:     protected $secured;
      76:
      77:     /**
      78:      * The value for the hidden field.
      79:      * Note: this column has a database default value of: 1
      80:      * @var        int
      81:      */
      82:     protected $hidden;
      83:
      84:     /**
      85:      * The value for the created_at field.
      86:      * @var        string
      87:      */
      88:     protected $created_at;
      89:
      90:     /**
      91:      * The value for the updated_at field.
      92:      * @var        string
      93:      */
      94:     protected $updated_at;
      95:
      96:     /**
      97:      * @var        PropelObjectCollection|ConfigI18n[] Collection to store aggregation of ConfigI18n objects.
      98:      */
      99:     protected $collConfigI18ns;
     100:     protected $collConfigI18nsPartial;
     101:
     102:     /**
     103:      * Flag to prevent endless save loop, if this object is referenced
     104:      * by another object which falls in this transaction.
     105:      * @var        boolean
     106:      */
     107:     protected $alreadyInSave = false;
     108:
     109:     /**
     110:      * Flag to prevent endless validation loop, if this object is referenced
     111:      * by another object which falls in this transaction.
     112:      * @var        boolean
     113:      */
     114:     protected $alreadyInValidation = false;
     115:
     116:     /**
     117:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
     118:      * @var        boolean
     119:      */
     120:     protected $alreadyInClearAllReferencesDeep = false;
     121:
     122:     // i18n behavior
     123:
     124:     /**
     125:      * Current locale
     126:      * @var        string
     127:      */
     128:     protected $currentLocale = 'en_US';
     129:
     130:     /**
     131:      * Current translation objects
     132:      * @var        array[ConfigI18n]
     133:      */
     134:     protected $currentTranslations;
     135:
     136:     /**
     137:      * An array of objects scheduled for deletion.
     138:      * @var     PropelObjectCollection
     139:      */
     140:     protected $configI18nsScheduledForDeletion = null;
     141:
     142:     /**
     143:      * Applies default values to this object.
     144:      * This method should be called from the object's constructor (or
     145:      * equivalent initialization method).
     146:      * @see        __construct()
     147:      */
     148:     public function applyDefaultValues()
     149:     {
     150:         $this->secured = 1;
     151:         $this->hidden = 1;
     152:     }
     153:
     154:     /**
     155:      * Initializes internal state of BaseConfig object.
     156:      * @see        applyDefaults()
     157:      */
     158:     public function __construct()
     159:     {
     160:         parent::__construct();
     161:         $this->applyDefaultValues();
     162:     }
     163:
     164:     /**
     165:      * Get the [id] column value.
     166:      *
     167:      * @return int
     168:      */
     169:     public function getId()
     170:     {
     171:         return $this->id;
     172:     }
     173:
     174:     /**
     175:      * Get the [name] column value.
     176:      *
     177:      * @return string
     178:      */
     179:     public function getName()
     180:     {
     181:         return $this->name;
     182:     }
     183:
     184:     /**
     185:      * Get the [value] column value.
     186:      *
     187:      * @return string
     188:      */
     189:     public function getValue()
     190:     {
     191:         return $this->value;
     192:     }
     193:
     194:     /**
     195:      * Get the [secured] column value.
     196:      *
     197:      * @return int
     198:      */
     199:     public function getSecured()
     200:     {
     201:         return $this->secured;
     202:     }
     203:
     204:     /**
     205:      * Get the [hidden] column value.
     206:      *
     207:      * @return int
     208:      */
     209:     public function getHidden()
     210:     {
     211:         return $this->hidden;
     212:     }
     213:
     214:     /**
     215:      * Get the [optionally formatted] temporal [created_at] column value.
     216:      *
     217:      *
     218:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     219:      *               If format is null, then the raw DateTime object will be returned.
     220:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     221:      * @throws PropelException - if unable to parse/validate the date/time value.
     222:      */
     223:     public function getCreatedAt($format = 'Y-m-d H:i:s')
     224:     {
     225:         if ($this->created_at === null) {
     226:             return null;
     227:         }
     228:
     229:         if ($this->created_at === '0000-00-00 00:00:00') {
     230:             // while technically this is not a default value of null,
     231:             // this seems to be closest in meaning.
     232:             return null;
     233:         }
     234:
     235:         try {
     236:             $dt = new DateTime($this->created_at);
     237:         } catch (Exception $x) {
     238:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
     239:         }
     240:
     241:         if ($format === null) {
     242:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     243:             return $dt;
     244:         }
     245:
     246:         if (strpos($format, '%') !== false) {
     247:             return strftime($format, $dt->format('U'));
     248:         }
     249:
     250:         return $dt->format($format);
     251:
     252:     }
     253:
     254:     /**
     255:      * Get the [optionally formatted] temporal [updated_at] column value.
     256:      *
     257:      *
     258:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     259:      *               If format is null, then the raw DateTime object will be returned.
     260:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     261:      * @throws PropelException - if unable to parse/validate the date/time value.
     262:      */
     263:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
     264:     {
     265:         if ($this->updated_at === null) {
     266:             return null;
     267:         }
     268:
     269:         if ($this->updated_at === '0000-00-00 00:00:00') {
     270:             // while technically this is not a default value of null,
     271:             // this seems to be closest in meaning.
     272:             return null;
     273:         }
     274:
     275:         try {
     276:             $dt = new DateTime($this->updated_at);
     277:         } catch (Exception $x) {
     278:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
     279:         }
     280:
     281:         if ($format === null) {
     282:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     283:             return $dt;
     284:         }
     285:
     286:         if (strpos($format, '%') !== false) {
     287:             return strftime($format, $dt->format('U'));
     288:         }
     289:
     290:         return $dt->format($format);
     291:
     292:     }
     293:
     294:     /**
     295:      * Set the value of [id] column.
     296:      *
     297:      * @param int $v new value
     298:      * @return Config The current object (for fluent API support)
     299:      */
     300:     public function setId($v)
     301:     {
     302:         if ($v !== null && is_numeric($v)) {
     303:             $v = (int) $v;
     304:         }
     305:
     306:         if ($this->id !== $v) {
     307:             $this->id = $v;
     308:             $this->modifiedColumns[] = ConfigPeer::ID;
     309:         }
     310:
     311:
     312:         return $this;
     313:     } // setId()
     314:
     315:     /**
     316:      * Set the value of [name] column.
     317:      *
     318:      * @param string $v new value
     319:      * @return Config The current object (for fluent API support)
     320:      */
     321:     public function setName($v)
     322:     {
     323:         if ($v !== null && is_numeric($v)) {
     324:             $v = (string) $v;
     325:         }
     326:
     327:         if ($this->name !== $v) {
     328:             $this->name = $v;
     329:             $this->modifiedColumns[] = ConfigPeer::NAME;
     330:         }
     331:
     332:
     333:         return $this;
     334:     } // setName()
     335:
     336:     /**
     337:      * Set the value of [value] column.
     338:      *
     339:      * @param string $v new value
     340:      * @return Config The current object (for fluent API support)
     341:      */
     342:     public function setValue($v)
     343:     {
     344:         if ($v !== null && is_numeric($v)) {
     345:             $v = (string) $v;
     346:         }
     347:
     348:         if ($this->value !== $v) {
     349:             $this->value = $v;
     350:             $this->modifiedColumns[] = ConfigPeer::VALUE;
     351:         }
     352:
     353:
     354:         return $this;
     355:     } // setValue()
     356:
     357:     /**
     358:      * Set the value of [secured] column.
     359:      *
     360:      * @param int $v new value
     361:      * @return Config The current object (for fluent API support)
     362:      */
     363:     public function setSecured($v)
     364:     {
     365:         if ($v !== null && is_numeric($v)) {
     366:             $v = (int) $v;
     367:         }
     368:
     369:         if ($this->secured !== $v) {
     370:             $this->secured = $v;
     371:             $this->modifiedColumns[] = ConfigPeer::SECURED;
     372:         }
     373:
     374:
     375:         return $this;
     376:     } // setSecured()
     377:
     378:     /**
     379:      * Set the value of [hidden] column.
     380:      *
     381:      * @param int $v new value
     382:      * @return Config The current object (for fluent API support)
     383:      */
     384:     public function setHidden($v)
     385:     {
     386:         if ($v !== null && is_numeric($v)) {
     387:             $v = (int) $v;
     388:         }
     389:
     390:         if ($this->hidden !== $v) {
     391:             $this->hidden = $v;
     392:             $this->modifiedColumns[] = ConfigPeer::HIDDEN;
     393:         }
     394:
     395:
     396:         return $this;
     397:     } // setHidden()
     398:
     399:     /**
     400:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
     401:      *
     402:      * @param mixed $v string, integer (timestamp), or DateTime value.
     403:      *               Empty strings are treated as null.
     404:      * @return Config The current object (for fluent API support)
     405:      */
     406:     public function setCreatedAt($v)
     407:     {
     408:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     409:         if ($this->created_at !== null || $dt !== null) {
     410:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     411:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     412:             if ($currentDateAsString !== $newDateAsString) {
     413:                 $this->created_at = $newDateAsString;
     414:                 $this->modifiedColumns[] = ConfigPeer::CREATED_AT;
     415:             }
     416:         } // if either are not null
     417:
     418:
     419:         return $this;
     420:     } // setCreatedAt()
     421:
     422:     /**
     423:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
     424:      *
     425:      * @param mixed $v string, integer (timestamp), or DateTime value.
     426:      *               Empty strings are treated as null.
     427:      * @return Config The current object (for fluent API support)
     428:      */
     429:     public function setUpdatedAt($v)
     430:     {
     431:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     432:         if ($this->updated_at !== null || $dt !== null) {
     433:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     434:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     435:             if ($currentDateAsString !== $newDateAsString) {
     436:                 $this->updated_at = $newDateAsString;
     437:                 $this->modifiedColumns[] = ConfigPeer::UPDATED_AT;
     438:             }
     439:         } // if either are not null
     440:
     441:
     442:         return $this;
     443:     } // setUpdatedAt()
     444:
     445:     /**
     446:      * Indicates whether the columns in this object are only set to default values.
     447:      *
     448:      * This method can be used in conjunction with isModified() to indicate whether an object is both
     449:      * modified _and_ has some values set which are non-default.
     450:      *
     451:      * @return boolean Whether the columns in this object are only been set with default values.
     452:      */
     453:     public function hasOnlyDefaultValues()
     454:     {
     455:             if ($this->secured !== 1) {
     456:                 return false;
     457:             }
     458:
     459:             if ($this->hidden !== 1) {
     460:                 return false;
     461:             }
     462:
     463:         // otherwise, everything was equal, so return true
     464:         return true;
     465:     } // hasOnlyDefaultValues()
     466:
     467:     /**
     468:      * Hydrates (populates) the object variables with values from the database resultset.
     469:      *
     470:      * An offset (0-based "start column") is specified so that objects can be hydrated
     471:      * with a subset of the columns in the resultset rows.  This is needed, for example,
     472:      * for results of JOIN queries where the resultset row includes columns from two or
     473:      * more tables.
     474:      *
     475:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     476:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     477:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     478:      * @return int             next starting column
     479:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     480:      */
     481:     public function hydrate($row, $startcol = 0, $rehydrate = false)
     482:     {
     483:         try {
     484:
     485:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
     486:             $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
     487:             $this->value = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
     488:             $this->secured = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
     489:             $this->hidden = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
     490:             $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
     491:             $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
     492:             $this->resetModified();
     493:
     494:             $this->setNew(false);
     495:
     496:             if ($rehydrate) {
     497:                 $this->ensureConsistency();
     498:             }
     499:             $this->postHydrate($row, $startcol, $rehydrate);
     500:             return $startcol + 7; // 7 = ConfigPeer::NUM_HYDRATE_COLUMNS.
     501:
     502:         } catch (Exception $e) {
     503:             throw new PropelException("Error populating Config object", $e);
     504:         }
     505:     }
     506:
     507:     /**
     508:      * Checks and repairs the internal consistency of the object.
     509:      *
     510:      * This method is executed after an already-instantiated object is re-hydrated
     511:      * from the database.  It exists to check any foreign keys to make sure that
     512:      * the objects related to the current object are correct based on foreign key.
     513:      *
     514:      * You can override this method in the stub class, but you should always invoke
     515:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
     516:      * in case your model changes.
     517:      *
     518:      * @throws PropelException
     519:      */
     520:     public function ensureConsistency()
     521:     {
     522:
     523:     } // ensureConsistency
     524:
     525:     /**
     526:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     527:      *
     528:      * This will only work if the object has been saved and has a valid primary key set.
     529:      *
     530:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
     531:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
     532:      * @return void
     533:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     534:      */
     535:     public function reload($deep = false, PropelPDO $con = null)
     536:     {
     537:         if ($this->isDeleted()) {
     538:             throw new PropelException("Cannot reload a deleted object.");
     539:         }
     540:
     541:         if ($this->isNew()) {
     542:             throw new PropelException("Cannot reload an unsaved object.");
     543:         }
     544:
     545:         if ($con === null) {
     546:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     547:         }
     548:
     549:         // We don't need to alter the object instance pool; we're just modifying this instance
     550:         // already in the pool.
     551:
     552:         $stmt = ConfigPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
     553:         $row = $stmt->fetch(PDO::FETCH_NUM);
     554:         $stmt->closeCursor();
     555:         if (!$row) {
     556:             throw new PropelException('Cannot find matching row in the database to reload object values.');
     557:         }
     558:         $this->hydrate($row, 0, true); // rehydrate
     559:
     560:         if ($deep) {  // also de-associate any related objects?
     561:
     562:             $this->collConfigI18ns = null;
     563:
     564:         } // if (deep)
     565:     }
     566:
     567:     /**
     568:      * Removes this object from datastore and sets delete attribute.
     569:      *
     570:      * @param PropelPDO $con
     571:      * @return void
     572:      * @throws PropelException
     573:      * @throws Exception
     574:      * @see        BaseObject::setDeleted()
     575:      * @see        BaseObject::isDeleted()
     576:      */
     577:     public function delete(PropelPDO $con = null)
     578:     {
     579:         if ($this->isDeleted()) {
     580:             throw new PropelException("This object has already been deleted.");
     581:         }
     582:
     583:         if ($con === null) {
     584:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     585:         }
     586:
     587:         $con->beginTransaction();
     588:         try {
     589:             $deleteQuery = ConfigQuery::create()
     590:                 ->filterByPrimaryKey($this->getPrimaryKey());
     591:             $ret = $this->preDelete($con);
     592:             if ($ret) {
     593:                 $deleteQuery->delete($con);
     594:                 $this->postDelete($con);
     595:                 $con->commit();
     596:                 $this->setDeleted(true);
     597:             } else {
     598:                 $con->commit();
     599:             }
     600:         } catch (Exception $e) {
     601:             $con->rollBack();
     602:             throw $e;
     603:         }
     604:     }
     605:
     606:     /**
     607:      * Persists this object to the database.
     608:      *
     609:      * If the object is new, it inserts it; otherwise an update is performed.
     610:      * All modified related objects will also be persisted in the doSave()
     611:      * method.  This method wraps all precipitate database operations in a
     612:      * single transaction.
     613:      *
     614:      * @param PropelPDO $con
     615:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     616:      * @throws PropelException
     617:      * @throws Exception
     618:      * @see        doSave()
     619:      */
     620:     public function save(PropelPDO $con = null)
     621:     {
     622:         if ($this->isDeleted()) {
     623:             throw new PropelException("You cannot save an object that has been deleted.");
     624:         }
     625:
     626:         if ($con === null) {
     627:             $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     628:         }
     629:
     630:         $con->beginTransaction();
     631:         $isInsert = $this->isNew();
     632:         try {
     633:             $ret = $this->preSave($con);
     634:             if ($isInsert) {
     635:                 $ret = $ret && $this->preInsert($con);
     636:                 // timestampable behavior
     637:                 if (!$this->isColumnModified(ConfigPeer::CREATED_AT)) {
     638:                     $this->setCreatedAt(time());
     639:                 }
     640:                 if (!$this->isColumnModified(ConfigPeer::UPDATED_AT)) {
     641:                     $this->setUpdatedAt(time());
     642:                 }
     643:             } else {
     644:                 $ret = $ret && $this->preUpdate($con);
     645:                 // timestampable behavior
     646:                 if ($this->isModified() && !$this->isColumnModified(ConfigPeer::UPDATED_AT)) {
     647:                     $this->setUpdatedAt(time());
     648:                 }
     649:             }
     650:             if ($ret) {
     651:                 $affectedRows = $this->doSave($con);
     652:                 if ($isInsert) {
     653:                     $this->postInsert($con);
     654:                 } else {
     655:                     $this->postUpdate($con);
     656:                 }
     657:                 $this->postSave($con);
     658:                 ConfigPeer::addInstanceToPool($this);
     659:             } else {
     660:                 $affectedRows = 0;
     661:             }
     662:             $con->commit();
     663:
     664:             return $affectedRows;
     665:         } catch (Exception $e) {
     666:             $con->rollBack();
     667:             throw $e;
     668:         }
     669:     }
     670:
     671:     /**
     672:      * Performs the work of inserting or updating the row in the database.
     673:      *
     674:      * If the object is new, it inserts it; otherwise an update is performed.
     675:      * All related objects are also updated in this method.
     676:      *
     677:      * @param PropelPDO $con
     678:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     679:      * @throws PropelException
     680:      * @see        save()
     681:      */
     682:     protected function doSave(PropelPDO $con)
     683:     {
     684:         $affectedRows = 0; // initialize var to track total num of affected rows
     685:         if (!$this->alreadyInSave) {
     686:             $this->alreadyInSave = true;
     687:
     688:             if ($this->isNew() || $this->isModified()) {
     689:                 // persist changes
     690:                 if ($this->isNew()) {
     691:                     $this->doInsert($con);
     692:                 } else {
     693:                     $this->doUpdate($con);
     694:                 }
     695:                 $affectedRows += 1;
     696:                 $this->resetModified();
     697:             }
     698:
     699:             if ($this->configI18nsScheduledForDeletion !== null) {
     700:                 if (!$this->configI18nsScheduledForDeletion->isEmpty()) {
     701:                     ConfigI18nQuery::create()
     702:                         ->filterByPrimaryKeys($this->configI18nsScheduledForDeletion->getPrimaryKeys(false))
     703:                         ->delete($con);
     704:                     $this->configI18nsScheduledForDeletion = null;
     705:                 }
     706:             }
     707:
     708:             if ($this->collConfigI18ns !== null) {
     709:                 foreach ($this->collConfigI18ns as $referrerFK) {
     710:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
     711:                         $affectedRows += $referrerFK->save($con);
     712:                     }
     713:                 }
     714:             }
     715:
     716:             $this->alreadyInSave = false;
     717:
     718:         }
     719:
     720:         return $affectedRows;
     721:     } // doSave()
     722:
     723:     /**
     724:      * Insert the row in the database.
     725:      *
     726:      * @param PropelPDO $con
     727:      *
     728:      * @throws PropelException
     729:      * @see        doSave()
     730:      */
     731:     protected function doInsert(PropelPDO $con)
     732:     {
     733:         $modifiedColumns = array();
     734:         $index = 0;
     735:
     736:         $this->modifiedColumns[] = ConfigPeer::ID;
     737:         if (null !== $this->id) {
     738:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigPeer::ID . ')');
     739:         }
     740:
     741:          // check the columns in natural order for more readable SQL queries
     742:         if ($this->isColumnModified(ConfigPeer::ID)) {
     743:             $modifiedColumns[':p' . $index++]  = '`id`';
     744:         }
     745:         if ($this->isColumnModified(ConfigPeer::NAME)) {
     746:             $modifiedColumns[':p' . $index++]  = '`name`';
     747:         }
     748:         if ($this->isColumnModified(ConfigPeer::VALUE)) {
     749:             $modifiedColumns[':p' . $index++]  = '`value`';
     750:         }
     751:         if ($this->isColumnModified(ConfigPeer::SECURED)) {
     752:             $modifiedColumns[':p' . $index++]  = '`secured`';
     753:         }
     754:         if ($this->isColumnModified(ConfigPeer::HIDDEN)) {
     755:             $modifiedColumns[':p' . $index++]  = '`hidden`';
     756:         }
     757:         if ($this->isColumnModified(ConfigPeer::CREATED_AT)) {
     758:             $modifiedColumns[':p' . $index++]  = '`created_at`';
     759:         }
     760:         if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) {
     761:             $modifiedColumns[':p' . $index++]  = '`updated_at`';
     762:         }
     763:
     764:         $sql = sprintf(
     765:             'INSERT INTO `config` (%s) VALUES (%s)',
     766:             implode(', ', $modifiedColumns),
     767:             implode(', ', array_keys($modifiedColumns))
     768:         );
     769:
     770:         try {
     771:             $stmt = $con->prepare($sql);
     772:             foreach ($modifiedColumns as $identifier => $columnName) {
     773:                 switch ($columnName) {
     774:                     case '`id`':
     775:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
     776:                         break;
     777:                     case '`name`':
     778:                         $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
     779:                         break;
     780:                     case '`value`':
     781:                         $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
     782:                         break;
     783:                     case '`secured`':
     784:                         $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT);
     785:                         break;
     786:                     case '`hidden`':
     787:                         $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT);
     788:                         break;
     789:                     case '`created_at`':
     790:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
     791:                         break;
     792:                     case '`updated_at`':
     793:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
     794:                         break;
     795:                 }
     796:             }
     797:             $stmt->execute();
     798:         } catch (Exception $e) {
     799:             Propel::log($e->getMessage(), Propel::LOG_ERR);
     800:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     801:         }
     802:
     803:         try {
     804:             $pk = $con->lastInsertId();
     805:         } catch (Exception $e) {
     806:             throw new PropelException('Unable to get autoincrement id.', $e);
     807:         }
     808:         $this->setId($pk);
     809:
     810:         $this->setNew(false);
     811:     }
     812:
     813:     /**
     814:      * Update the row in the database.
     815:      *
     816:      * @param PropelPDO $con
     817:      *
     818:      * @see        doSave()
     819:      */
     820:     protected function doUpdate(PropelPDO $con)
     821:     {
     822:         $selectCriteria = $this->buildPkeyCriteria();
     823:         $valuesCriteria = $this->buildCriteria();
     824:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
     825:     }
     826:
     827:     /**
     828:      * Array of ValidationFailed objects.
     829:      * @var        array ValidationFailed[]
     830:      */
     831:     protected $validationFailures = array();
     832:
     833:     /**
     834:      * Gets any ValidationFailed objects that resulted from last call to validate().
     835:      *
     836:      *
     837:      * @return array ValidationFailed[]
     838:      * @see        validate()
     839:      */
     840:     public function getValidationFailures()
     841:     {
     842:         return $this->validationFailures;
     843:     }
     844:
     845:     /**
     846:      * Validates the objects modified field values and all objects related to this table.
     847:      *
     848:      * If $columns is either a column name or an array of column names
     849:      * only those columns are validated.
     850:      *
     851:      * @param mixed $columns Column name or an array of column names.
     852:      * @return boolean Whether all columns pass validation.
     853:      * @see        doValidate()
     854:      * @see        getValidationFailures()
     855:      */
     856:     public function validate($columns = null)
     857:     {
     858:         $res = $this->doValidate($columns);
     859:         if ($res === true) {
     860:             $this->validationFailures = array();
     861:
     862:             return true;
     863:         }
     864:
     865:         $this->validationFailures = $res;
     866:
     867:         return false;
     868:     }
     869:
     870:     /**
     871:      * This function performs the validation work for complex object models.
     872:      *
     873:      * In addition to checking the current object, all related objects will
     874:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
     875:      * an aggreagated array of ValidationFailed objects will be returned.
     876:      *
     877:      * @param array $columns Array of column names to validate.
     878:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     879:      */
     880:     protected function doValidate($columns = null)
     881:     {
     882:         if (!$this->alreadyInValidation) {
     883:             $this->alreadyInValidation = true;
     884:             $retval = null;
     885:
     886:             $failureMap = array();
     887:
     888:
     889:             if (($retval = ConfigPeer::doValidate($this, $columns)) !== true) {
     890:                 $failureMap = array_merge($failureMap, $retval);
     891:             }
     892:
     893:
     894:                 if ($this->collConfigI18ns !== null) {
     895:                     foreach ($this->collConfigI18ns as $referrerFK) {
     896:                         if (!$referrerFK->validate($columns)) {
     897:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     898:                         }
     899:                     }
     900:                 }
     901:
     902:
     903:             $this->alreadyInValidation = false;
     904:         }
     905:
     906:         return (!empty($failureMap) ? $failureMap : true);
     907:     }
     908:
     909:     /**
     910:      * Retrieves a field from the object by name passed in as a string.
     911:      *
     912:      * @param string $name name
     913:      * @param string $type The type of fieldname the $name is of:
     914:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     915:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     916:      *               Defaults to BasePeer::TYPE_PHPNAME
     917:      * @return mixed Value of field.
     918:      */
     919:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
     920:     {
     921:         $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     922:         $field = $this->getByPosition($pos);
     923:
     924:         return $field;
     925:     }
     926:
     927:     /**
     928:      * Retrieves a field from the object by Position as specified in the xml schema.
     929:      * Zero-based.
     930:      *
     931:      * @param int $pos position in xml schema
     932:      * @return mixed Value of field at $pos
     933:      */
     934:     public function getByPosition($pos)
     935:     {
     936:         switch ($pos) {
     937:             case 0:
     938:                 return $this->getId();
     939:                 break;
     940:             case 1:
     941:                 return $this->getName();
     942:                 break;
     943:             case 2:
     944:                 return $this->getValue();
     945:                 break;
     946:             case 3:
     947:                 return $this->getSecured();
     948:                 break;
     949:             case 4:
     950:                 return $this->getHidden();
     951:                 break;
     952:             case 5:
     953:                 return $this->getCreatedAt();
     954:                 break;
     955:             case 6:
     956:                 return $this->getUpdatedAt();
     957:                 break;
     958:             default:
     959:                 return null;
     960:                 break;
     961:         } // switch()
     962:     }
     963:
     964:     /**
     965:      * Exports the object as an array.
     966:      *
     967:      * You can specify the key type of the array by passing one of the class
     968:      * type constants.
     969:      *
     970:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     971:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     972:      *                    Defaults to BasePeer::TYPE_PHPNAME.
     973:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     974:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     975:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     976:      *
     977:      * @return array an associative array containing the field names (as keys) and field values
     978:      */
     979:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
     980:     {
     981:         if (isset($alreadyDumpedObjects['Config'][$this->getPrimaryKey()])) {
     982:             return '*RECURSION*';
     983:         }
     984:         $alreadyDumpedObjects['Config'][$this->getPrimaryKey()] = true;
     985:         $keys = ConfigPeer::getFieldNames($keyType);
     986:         $result = array(
     987:             $keys[0] => $this->getId(),
     988:             $keys[1] => $this->getName(),
     989:             $keys[2] => $this->getValue(),
     990:             $keys[3] => $this->getSecured(),
     991:             $keys[4] => $this->getHidden(),
     992:             $keys[5] => $this->getCreatedAt(),
     993:             $keys[6] => $this->getUpdatedAt(),
     994:         );
     995:         if ($includeForeignObjects) {
     996:             if (null !== $this->collConfigI18ns) {
     997:                 $result['ConfigI18ns'] = $this->collConfigI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
     998:             }
     999:         }
    1000:
    1001:         return $result;
    1002:     }
    1003:
    1004:     /**
    1005:      * Sets a field from the object by name passed in as a string.
    1006:      *
    1007:      * @param string $name peer name
    1008:      * @param mixed $value field value
    1009:      * @param string $type The type of fieldname the $name is of:
    1010:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
    1011:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
    1012:      *                     Defaults to BasePeer::TYPE_PHPNAME
    1013:      * @return void
    1014:      */
    1015:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
    1016:     {
    1017:         $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
    1018:
    1019:         $this->setByPosition($pos, $value);
    1020:     }
    1021:
    1022:     /**
    1023:      * Sets a field from the object by Position as specified in the xml schema.
    1024:      * Zero-based.
    1025:      *
    1026:      * @param int $pos position in xml schema
    1027:      * @param mixed $value field value
    1028:      * @return void
    1029:      */
    1030:     public function setByPosition($pos, $value)
    1031:     {
    1032:         switch ($pos) {
    1033:             case 0:
    1034:                 $this->setId($value);
    1035:                 break;
    1036:             case 1:
    1037:                 $this->setName($value);
    1038:                 break;
    1039:             case 2:
    1040:                 $this->setValue($value);
    1041:                 break;
    1042:             case 3:
    1043:                 $this->setSecured($value);
    1044:                 break;
    1045:             case 4:
    1046:                 $this->setHidden($value);
    1047:                 break;
    1048:             case 5:
    1049:                 $this->setCreatedAt($value);
    1050:                 break;
    1051:             case 6:
    1052:                 $this->setUpdatedAt($value);
    1053:                 break;
    1054:         } // switch()
    1055:     }
    1056:
    1057:     /**
    1058:      * Populates the object using an array.
    1059:      *
    1060:      * This is particularly useful when populating an object from one of the
    1061:      * request arrays (e.g. $_POST).  This method goes through the column
    1062:      * names, checking to see whether a matching key exists in populated
    1063:      * array. If so the setByName() method is called for that column.
    1064:      *
    1065:      * You can specify the key type of the array by additionally passing one
    1066:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
    1067:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
    1068:      * The default key type is the column's BasePeer::TYPE_PHPNAME
    1069:      *
    1070:      * @param array  $arr     An array to populate the object from.
    1071:      * @param string $keyType The type of keys the array uses.
    1072:      * @return void
    1073:      */
    1074:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    1075:     {
    1076:         $keys = ConfigPeer::getFieldNames($keyType);
    1077:
    1078:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
    1079:         if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
    1080:         if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
    1081:         if (array_key_exists($keys[3], $arr)) $this->setSecured($arr[$keys[3]]);
    1082:         if (array_key_exists($keys[4], $arr)) $this->setHidden($arr[$keys[4]]);
    1083:         if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
    1084:         if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
    1085:     }
    1086:
    1087:     /**
    1088:      * Build a Criteria object containing the values of all modified columns in this object.
    1089:      *
    1090:      * @return Criteria The Criteria object containing all modified values.
    1091:      */
    1092:     public function buildCriteria()
    1093:     {
    1094:         $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
    1095:
    1096:         if ($this->isColumnModified(ConfigPeer::ID)) $criteria->add(ConfigPeer::ID, $this->id);
    1097:         if ($this->isColumnModified(ConfigPeer::NAME)) $criteria->add(ConfigPeer::NAME, $this->name);
    1098:         if ($this->isColumnModified(ConfigPeer::VALUE)) $criteria->add(ConfigPeer::VALUE, $this->value);
    1099:         if ($this->isColumnModified(ConfigPeer::SECURED)) $criteria->add(ConfigPeer::SECURED, $this->secured);
    1100:         if ($this->isColumnModified(ConfigPeer::HIDDEN)) $criteria->add(ConfigPeer::HIDDEN, $this->hidden);
    1101:         if ($this->isColumnModified(ConfigPeer::CREATED_AT)) $criteria->add(ConfigPeer::CREATED_AT, $this->created_at);
    1102:         if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) $criteria->add(ConfigPeer::UPDATED_AT, $this->updated_at);
    1103:
    1104:         return $criteria;
    1105:     }
    1106:
    1107:     /**
    1108:      * Builds a Criteria object containing the primary key for this object.
    1109:      *
    1110:      * Unlike buildCriteria() this method includes the primary key values regardless
    1111:      * of whether or not they have been modified.
    1112:      *
    1113:      * @return Criteria The Criteria object containing value(s) for primary key(s).
    1114:      */
    1115:     public function buildPkeyCriteria()
    1116:     {
    1117:         $criteria = new Criteria(ConfigPeer::DATABASE_NAME);
    1118:         $criteria->add(ConfigPeer::ID, $this->id);
    1119:
    1120:         return $criteria;
    1121:     }
    1122:
    1123:     /**
    1124:      * Returns the primary key for this object (row).
    1125:      * @return int
    1126:      */
    1127:     public function getPrimaryKey()
    1128:     {
    1129:         return $this->getId();
    1130:     }
    1131:
    1132:     /**
    1133:      * Generic method to set the primary key (id column).
    1134:      *
    1135:      * @param  int $key Primary key.
    1136:      * @return void
    1137:      */
    1138:     public function setPrimaryKey($key)
    1139:     {
    1140:         $this->setId($key);
    1141:     }
    1142:
    1143:     /**
    1144:      * Returns true if the primary key for this object is null.
    1145:      * @return boolean
    1146:      */
    1147:     public function isPrimaryKeyNull()
    1148:     {
    1149:
    1150:         return null === $this->getId();
    1151:     }
    1152:
    1153:     /**
    1154:      * Sets contents of passed object to values from current object.
    1155:      *
    1156:      * If desired, this method can also make copies of all associated (fkey referrers)
    1157:      * objects.
    1158:      *
    1159:      * @param object $copyObj An object of Config (or compatible) type.
    1160:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1161:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
    1162:      * @throws PropelException
    1163:      */
    1164:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    1165:     {
    1166:         $copyObj->setName($this->getName());
    1167:         $copyObj->setValue($this->getValue());
    1168:         $copyObj->setSecured($this->getSecured());
    1169:         $copyObj->setHidden($this->getHidden());
    1170:         $copyObj->setCreatedAt($this->getCreatedAt());
    1171:         $copyObj->setUpdatedAt($this->getUpdatedAt());
    1172:
    1173:         if ($deepCopy && !$this->startCopy) {
    1174:             // important: temporarily setNew(false) because this affects the behavior of
    1175:             // the getter/setter methods for fkey referrer objects.
    1176:             $copyObj->setNew(false);
    1177:             // store object hash to prevent cycle
    1178:             $this->startCopy = true;
    1179:
    1180:             foreach ($this->getConfigI18ns() as $relObj) {
    1181:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1182:                     $copyObj->addConfigI18n($relObj->copy($deepCopy));
    1183:                 }
    1184:             }
    1185:
    1186:             //unflag object copy
    1187:             $this->startCopy = false;
    1188:         } // if ($deepCopy)
    1189:
    1190:         if ($makeNew) {
    1191:             $copyObj->setNew(true);
    1192:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
    1193:         }
    1194:     }
    1195:
    1196:     /**
    1197:      * Makes a copy of this object that will be inserted as a new row in table when saved.
    1198:      * It creates a new object filling in the simple attributes, but skipping any primary
    1199:      * keys that are defined for the table.
    1200:      *
    1201:      * If desired, this method can also make copies of all associated (fkey referrers)
    1202:      * objects.
    1203:      *
    1204:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1205:      * @return Config Clone of current object.
    1206:      * @throws PropelException
    1207:      */
    1208:     public function copy($deepCopy = false)
    1209:     {
    1210:         // we use get_class(), because this might be a subclass
    1211:         $clazz = get_class($this);
    1212:         $copyObj = new $clazz();
    1213:         $this->copyInto($copyObj, $deepCopy);
    1214:
    1215:         return $copyObj;
    1216:     }
    1217:
    1218:     /**
    1219:      * Returns a peer instance associated with this om.
    1220:      *
    1221:      * Since Peer classes are not to have any instance attributes, this method returns the
    1222:      * same instance for all member of this class. The method could therefore
    1223:      * be static, but this would prevent one from overriding the behavior.
    1224:      *
    1225:      * @return ConfigPeer
    1226:      */
    1227:     public function getPeer()
    1228:     {
    1229:         if (self::$peer === null) {
    1230:             self::$peer = new ConfigPeer();
    1231:         }
    1232:
    1233:         return self::$peer;
    1234:     }
    1235:
    1236:
    1237:     /**
    1238:      * Initializes a collection based on the name of a relation.
    1239:      * Avoids crafting an 'init[$relationName]s' method name
    1240:      * that wouldn't work when StandardEnglishPluralizer is used.
    1241:      *
    1242:      * @param string $relationName The name of the relation to initialize
    1243:      * @return void
    1244:      */
    1245:     public function initRelation($relationName)
    1246:     {
    1247:         if ('ConfigI18n' == $relationName) {
    1248:             $this->initConfigI18ns();
    1249:         }
    1250:     }
    1251:
    1252:     /**
    1253:      * Clears out the collConfigI18ns collection
    1254:      *
    1255:      * This does not modify the database; however, it will remove any associated objects, causing
    1256:      * them to be refetched by subsequent calls to accessor method.
    1257:      *
    1258:      * @return Config The current object (for fluent API support)
    1259:      * @see        addConfigI18ns()
    1260:      */
    1261:     public function clearConfigI18ns()
    1262:     {
    1263:         $this->collConfigI18ns = null; // important to set this to null since that means it is uninitialized
    1264:         $this->collConfigI18nsPartial = null;
    1265:
    1266:         return $this;
    1267:     }
    1268:
    1269:     /**
    1270:      * reset is the collConfigI18ns collection loaded partially
    1271:      *
    1272:      * @return void
    1273:      */
    1274:     public function resetPartialConfigI18ns($v = true)
    1275:     {
    1276:         $this->collConfigI18nsPartial = $v;
    1277:     }
    1278:
    1279:     /**
    1280:      * Initializes the collConfigI18ns collection.
    1281:      *
    1282:      * By default this just sets the collConfigI18ns collection to an empty array (like clearcollConfigI18ns());
    1283:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1284:      * to your application -- for example, setting the initial array to the values stored in database.
    1285:      *
    1286:      * @param boolean $overrideExisting If set to true, the method call initializes
    1287:      *                                        the collection even if it is not empty
    1288:      *
    1289:      * @return void
    1290:      */
    1291:     public function initConfigI18ns($overrideExisting = true)
    1292:     {
    1293:         if (null !== $this->collConfigI18ns && !$overrideExisting) {
    1294:             return;
    1295:         }
    1296:         $this->collConfigI18ns = new PropelObjectCollection();
    1297:         $this->collConfigI18ns->setModel('ConfigI18n');
    1298:     }
    1299:
    1300:     /**
    1301:      * Gets an array of ConfigI18n objects which contain a foreign key that references this object.
    1302:      *
    1303:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1304:      * Otherwise the results are fetched from the database the first time, then cached.
    1305:      * Next time the same method is called without $criteria, the cached collection is returned.
    1306:      * If this Config is new, it will return
    1307:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1308:      *
    1309:      * @param Criteria $criteria optional Criteria object to narrow the query
    1310:      * @param PropelPDO $con optional connection object
    1311:      * @return PropelObjectCollection|ConfigI18n[] List of ConfigI18n objects
    1312:      * @throws PropelException
    1313:      */
    1314:     public function getConfigI18ns($criteria = null, PropelPDO $con = null)
    1315:     {
    1316:         $partial = $this->collConfigI18nsPartial && !$this->isNew();
    1317:         if (null === $this->collConfigI18ns || null !== $criteria  || $partial) {
    1318:             if ($this->isNew() && null === $this->collConfigI18ns) {
    1319:                 // return empty collection
    1320:                 $this->initConfigI18ns();
    1321:             } else {
    1322:                 $collConfigI18ns = ConfigI18nQuery::create(null, $criteria)
    1323:                     ->filterByConfig($this)
    1324:                     ->find($con);
    1325:                 if (null !== $criteria) {
    1326:                     if (false !== $this->collConfigI18nsPartial && count($collConfigI18ns)) {
    1327:                       $this->initConfigI18ns(false);
    1328:
    1329:                       foreach($collConfigI18ns as $obj) {
    1330:                         if (false == $this->collConfigI18ns->contains($obj)) {
    1331:                           $this->collConfigI18ns->append($obj);
    1332:                         }
    1333:                       }
    1334:
    1335:                       $this->collConfigI18nsPartial = true;
    1336:                     }
    1337:
    1338:                     $collConfigI18ns->getInternalIterator()->rewind();
    1339:                     return $collConfigI18ns;
    1340:                 }
    1341:
    1342:                 if($partial && $this->collConfigI18ns) {
    1343:                     foreach($this->collConfigI18ns as $obj) {
    1344:                         if($obj->isNew()) {
    1345:                             $collConfigI18ns[] = $obj;
    1346:                         }
    1347:                     }
    1348:                 }
    1349:
    1350:                 $this->collConfigI18ns = $collConfigI18ns;
    1351:                 $this->collConfigI18nsPartial = false;
    1352:             }
    1353:         }
    1354:
    1355:         return $this->collConfigI18ns;
    1356:     }
    1357:
    1358:     /**
    1359:      * Sets a collection of ConfigI18n objects related by a one-to-many relationship
    1360:      * to the current object.
    1361:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1362:      * and new objects from the given Propel collection.
    1363:      *
    1364:      * @param PropelCollection $configI18ns A Propel collection.
    1365:      * @param PropelPDO $con Optional connection object
    1366:      * @return Config The current object (for fluent API support)
    1367:      */
    1368:     public function setConfigI18ns(PropelCollection $configI18ns, PropelPDO $con = null)
    1369:     {
    1370:         $configI18nsToDelete = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns);
    1371:
    1372:         $this->configI18nsScheduledForDeletion = unserialize(serialize($configI18nsToDelete));
    1373:
    1374:         foreach ($configI18nsToDelete as $configI18nRemoved) {
    1375:             $configI18nRemoved->setConfig(null);
    1376:         }
    1377:
    1378:         $this->collConfigI18ns = null;
    1379:         foreach ($configI18ns as $configI18n) {
    1380:             $this->addConfigI18n($configI18n);
    1381:         }
    1382:
    1383:         $this->collConfigI18ns = $configI18ns;
    1384:         $this->collConfigI18nsPartial = false;
    1385:
    1386:         return $this;
    1387:     }
    1388:
    1389:     /**
    1390:      * Returns the number of related ConfigI18n objects.
    1391:      *
    1392:      * @param Criteria $criteria
    1393:      * @param boolean $distinct
    1394:      * @param PropelPDO $con
    1395:      * @return int             Count of related ConfigI18n objects.
    1396:      * @throws PropelException
    1397:      */
    1398:     public function countConfigI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1399:     {
    1400:         $partial = $this->collConfigI18nsPartial && !$this->isNew();
    1401:         if (null === $this->collConfigI18ns || null !== $criteria || $partial) {
    1402:             if ($this->isNew() && null === $this->collConfigI18ns) {
    1403:                 return 0;
    1404:             }
    1405:
    1406:             if($partial && !$criteria) {
    1407:                 return count($this->getConfigI18ns());
    1408:             }
    1409:             $query = ConfigI18nQuery::create(null, $criteria);
    1410:             if ($distinct) {
    1411:                 $query->distinct();
    1412:             }
    1413:
    1414:             return $query
    1415:                 ->filterByConfig($this)
    1416:                 ->count($con);
    1417:         }
    1418:
    1419:         return count($this->collConfigI18ns);
    1420:     }
    1421:
    1422:     /**
    1423:      * Method called to associate a ConfigI18n object to this object
    1424:      * through the ConfigI18n foreign key attribute.
    1425:      *
    1426:      * @param    ConfigI18n $l ConfigI18n
    1427:      * @return Config The current object (for fluent API support)
    1428:      */
    1429:     public function addConfigI18n(ConfigI18n $l)
    1430:     {
    1431:         if ($l && $locale = $l->getLocale()) {
    1432:             $this->setLocale($locale);
    1433:             $this->currentTranslations[$locale] = $l;
    1434:         }
    1435:         if ($this->collConfigI18ns === null) {
    1436:             $this->initConfigI18ns();
    1437:             $this->collConfigI18nsPartial = true;
    1438:         }
    1439:         if (!in_array($l, $this->collConfigI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
    1440:             $this->doAddConfigI18n($l);
    1441:         }
    1442:
    1443:         return $this;
    1444:     }
    1445:
    1446:     /**
    1447:      * @param   ConfigI18n $configI18n The configI18n object to add.
    1448:      */
    1449:     protected function doAddConfigI18n($configI18n)
    1450:     {
    1451:         $this->collConfigI18ns[]= $configI18n;
    1452:         $configI18n->setConfig($this);
    1453:     }
    1454:
    1455:     /**
    1456:      * @param   ConfigI18n $configI18n The configI18n object to remove.
    1457:      * @return Config The current object (for fluent API support)
    1458:      */
    1459:     public function removeConfigI18n($configI18n)
    1460:     {
    1461:         if ($this->getConfigI18ns()->contains($configI18n)) {
    1462:             $this->collConfigI18ns->remove($this->collConfigI18ns->search($configI18n));
    1463:             if (null === $this->configI18nsScheduledForDeletion) {
    1464:                 $this->configI18nsScheduledForDeletion = clone $this->collConfigI18ns;
    1465:                 $this->configI18nsScheduledForDeletion->clear();
    1466:             }
    1467:             $this->configI18nsScheduledForDeletion[]= clone $configI18n;
    1468:             $configI18n->setConfig(null);
    1469:         }
    1470:
    1471:         return $this;
    1472:     }
    1473:
    1474:     /**
    1475:      * Clears the current object and sets all attributes to their default values
    1476:      */
    1477:     public function clear()
    1478:     {
    1479:         $this->id = null;
    1480:         $this->name = null;
    1481:         $this->value = null;
    1482:         $this->secured = null;
    1483:         $this->hidden = null;
    1484:         $this->created_at = null;
    1485:         $this->updated_at = null;
    1486:         $this->alreadyInSave = false;
    1487:         $this->alreadyInValidation = false;
    1488:         $this->alreadyInClearAllReferencesDeep = false;
    1489:         $this->clearAllReferences();
    1490:         $this->applyDefaultValues();
    1491:         $this->resetModified();
    1492:         $this->setNew(true);
    1493:         $this->setDeleted(false);
    1494:     }
    1495:
    1496:     /**
    1497:      * Resets all references to other model objects or collections of model objects.
    1498:      *
    1499:      * This method is a user-space workaround for PHP's inability to garbage collect
    1500:      * objects with circular references (even in PHP 5.3). This is currently necessary
    1501:      * when using Propel in certain daemon or large-volumne/high-memory operations.
    1502:      *
    1503:      * @param boolean $deep Whether to also clear the references on all referrer objects.
    1504:      */
    1505:     public function clearAllReferences($deep = false)
    1506:     {
    1507:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
    1508:             $this->alreadyInClearAllReferencesDeep = true;
    1509:             if ($this->collConfigI18ns) {
    1510:                 foreach ($this->collConfigI18ns as $o) {
    1511:                     $o->clearAllReferences($deep);
    1512:                 }
    1513:             }
    1514:
    1515:             $this->alreadyInClearAllReferencesDeep = false;
    1516:         } // if ($deep)
    1517:
    1518:         // i18n behavior
    1519:         $this->currentLocale = 'en_US';
    1520:         $this->currentTranslations = null;
    1521:
    1522:         if ($this->collConfigI18ns instanceof PropelCollection) {
    1523:             $this->collConfigI18ns->clearIterator();
    1524:         }
    1525:         $this->collConfigI18ns = null;
    1526:     }
    1527:
    1528:     /**
    1529:      * return the string representation of this object
    1530:      *
    1531:      * @return string
    1532:      */
    1533:     public function __toString()
    1534:     {
    1535:         return (string) $this->exportTo(ConfigPeer::DEFAULT_STRING_FORMAT);
    1536:     }
    1537:
    1538:     /**
    1539:      * return true is the object is in saving state
    1540:      *
    1541:      * @return boolean
    1542:      */
    1543:     public function isAlreadyInSave()
    1544:     {
    1545:         return $this->alreadyInSave;
    1546:     }
    1547:
    1548:     // timestampable behavior
    1549:
    1550:     /**
    1551:      * Mark the current object so that the update date doesn't get updated during next save
    1552:      *
    1553:      * @return     Config The current object (for fluent API support)
    1554:      */
    1555:     public function keepUpdateDateUnchanged()
    1556:     {
    1557:         $this->modifiedColumns[] = ConfigPeer::UPDATED_AT;
    1558:
    1559:         return $this;
    1560:     }
    1561:
    1562:     // i18n behavior
    1563:
    1564:     /**
    1565:      * Sets the locale for translations
    1566:      *
    1567:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    1568:      *
    1569:      * @return    Config The current object (for fluent API support)
    1570:      */
    1571:     public function setLocale($locale = 'en_US')
    1572:     {
    1573:         $this->currentLocale = $locale;
    1574:
    1575:         return $this;
    1576:     }
    1577:
    1578:     /**
    1579:      * Gets the locale for translations
    1580:      *
    1581:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
    1582:      */
    1583:     public function getLocale()
    1584:     {
    1585:         return $this->currentLocale;
    1586:     }
    1587:
    1588:     /**
    1589:      * Returns the current translation for a given locale
    1590:      *
    1591:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    1592:      * @param     PropelPDO $con an optional connection object
    1593:      *
    1594:      * @return ConfigI18n */
    1595:     public function getTranslation($locale = 'en_US', PropelPDO $con = null)
    1596:     {
    1597:         if (!isset($this->currentTranslations[$locale])) {
    1598:             if (null !== $this->collConfigI18ns) {
    1599:                 foreach ($this->collConfigI18ns as $translation) {
    1600:                     if ($translation->getLocale() == $locale) {
    1601:                         $this->currentTranslations[$locale] = $translation;
    1602:
    1603:                         return $translation;
    1604:                     }
    1605:                 }
    1606:             }
    1607:             if ($this->isNew()) {
    1608:                 $translation = new ConfigI18n();
    1609:                 $translation->setLocale($locale);
    1610:             } else {
    1611:                 $translation = ConfigI18nQuery::create()
    1612:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    1613:                     ->findOneOrCreate($con);
    1614:                 $this->currentTranslations[$locale] = $translation;
    1615:             }
    1616:             $this->addConfigI18n($translation);
    1617:         }
    1618:
    1619:         return $this->currentTranslations[$locale];
    1620:     }
    1621:
    1622:     /**
    1623:      * Remove the translation for a given locale
    1624:      *
    1625:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    1626:      * @param     PropelPDO $con an optional connection object
    1627:      *
    1628:      * @return    Config The current object (for fluent API support)
    1629:      */
    1630:     public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
    1631:     {
    1632:         if (!$this->isNew()) {
    1633:             ConfigI18nQuery::create()
    1634:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    1635:                 ->delete($con);
    1636:         }
    1637:         if (isset($this->currentTranslations[$locale])) {
    1638:             unset($this->currentTranslations[$locale]);
    1639:         }
    1640:         foreach ($this->collConfigI18ns as $key => $translation) {
    1641:             if ($translation->getLocale() == $locale) {
    1642:                 unset($this->collConfigI18ns[$key]);
    1643:                 break;
    1644:             }
    1645:         }
    1646:
    1647:         return $this;
    1648:     }
    1649:
    1650:     /**
    1651:      * Returns the current translation
    1652:      *
    1653:      * @param     PropelPDO $con an optional connection object
    1654:      *
    1655:      * @return ConfigI18n */
    1656:     public function getCurrentTranslation(PropelPDO $con = null)
    1657:     {
    1658:         return $this->getTranslation($this->getLocale(), $con);
    1659:     }
    1660:
    1661:
    1662:         /**
    1663:          * Get the [title] column value.
    1664:          *
    1665:          * @return string
    1666:          */
    1667:         public function getTitle()
    1668:         {
    1669:         return $this->getCurrentTranslation()->getTitle();
    1670:     }
    1671:
    1672:
    1673:         /**
    1674:          * Set the value of [title] column.
    1675:          *
    1676:          * @param string $v new value
    1677:          * @return ConfigI18n The current object (for fluent API support)
    1678:          */
    1679:         public function setTitle($v)
    1680:         {    $this->getCurrentTranslation()->setTitle($v);
    1681:
    1682:         return $this;
    1683:     }
    1684:
    1685:
    1686:         /**
    1687:          * Get the [description] column value.
    1688:          *
    1689:          * @return string
    1690:          */
    1691:         public function getDescription()
    1692:         {
    1693:         return $this->getCurrentTranslation()->getDescription();
    1694:     }
    1695:
    1696:
    1697:         /**
    1698:          * Set the value of [description] column.
    1699:          *
    1700:          * @param string $v new value
    1701:          * @return ConfigI18n The current object (for fluent API support)
    1702:          */
    1703:         public function setDescription($v)
    1704:         {    $this->getCurrentTranslation()->setDescription($v);
    1705:
    1706:         return $this;
    1707:     }
    1708:
    1709:
    1710:         /**
    1711:          * Get the [chapo] column value.
    1712:          *
    1713:          * @return string
    1714:          */
    1715:         public function getChapo()
    1716:         {
    1717:         return $this->getCurrentTranslation()->getChapo();
    1718:     }
    1719:
    1720:
    1721:         /**
    1722:          * Set the value of [chapo] column.
    1723:          *
    1724:          * @param string $v new value
    1725:          * @return ConfigI18n The current object (for fluent API support)
    1726:          */
    1727:         public function setChapo($v)
    1728:         {    $this->getCurrentTranslation()->setChapo($v);
    1729:
    1730:         return $this;
    1731:     }
    1732:
    1733:
    1734:         /**
    1735:          * Get the [postscriptum] column value.
    1736:          *
    1737:          * @return string
    1738:          */
    1739:         public function getPostscriptum()
    1740:         {
    1741:         return $this->getCurrentTranslation()->getPostscriptum();
    1742:     }
    1743:
    1744:
    1745:         /**
    1746:          * Set the value of [postscriptum] column.
    1747:          *
    1748:          * @param string $v new value
    1749:          * @return ConfigI18n The current object (for fluent API support)
    1750:          */
    1751:         public function setPostscriptum($v)
    1752:         {    $this->getCurrentTranslation()->setPostscriptum($v);
    1753:
    1754:         return $this;
    1755:     }
    1756:
    1757: }
    1758: