# File core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php | thelia

       1: <?php
       2:
       3: namespace Thelia\Model\om;
       4:
       5: use \BaseObject;
       6: use \BasePeer;
       7: use \Criteria;
       8: use \Exception;
       9: use \PDO;
      10: use \Persistent;
      11: use \Propel;
      12: use \PropelException;
      13: use \PropelPDO;
      14: use Thelia\Model\CustomerTitle;
      15: use Thelia\Model\CustomerTitleI18n;
      16: use Thelia\Model\CustomerTitleI18nPeer;
      17: use Thelia\Model\CustomerTitleI18nQuery;
      18: use Thelia\Model\CustomerTitleQuery;
      19:
      20: /**
      21:  * Base class that represents a row from the 'customer_title_i18n' table.
      22:  *
      23:  *
      24:  *
      25:  * @package    propel.generator.Thelia.Model.om
      26:  */
      27: abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent
      28: {
      29:     /**
      30:      * Peer class name
      31:      */
      32:     const PEER = 'Thelia\\Model\\CustomerTitleI18nPeer';
      33:
      34:     /**
      35:      * The Peer class.
      36:      * Instance provides a convenient way of calling static methods on a class
      37:      * that calling code may not be able to identify.
      38:      * @var        CustomerTitleI18nPeer
      39:      */
      40:     protected static $peer;
      41:
      42:     /**
      43:      * The flag var to prevent infinit loop in deep copy
      44:      * @var       boolean
      45:      */
      46:     protected $startCopy = false;
      47:
      48:     /**
      49:      * The value for the id field.
      50:      * @var        int
      51:      */
      52:     protected $id;
      53:
      54:     /**
      55:      * The value for the locale field.
      56:      * Note: this column has a database default value of: 'en_EN'
      57:      * @var        string
      58:      */
      59:     protected $locale;
      60:
      61:     /**
      62:      * The value for the short field.
      63:      * @var        string
      64:      */
      65:     protected $short;
      66:
      67:     /**
      68:      * The value for the long field.
      69:      * @var        string
      70:      */
      71:     protected $long;
      72:
      73:     /**
      74:      * @var        CustomerTitle
      75:      */
      76:     protected $aCustomerTitle;
      77:
      78:     /**
      79:      * Flag to prevent endless save loop, if this object is referenced
      80:      * by another object which falls in this transaction.
      81:      * @var        boolean
      82:      */
      83:     protected $alreadyInSave = false;
      84:
      85:     /**
      86:      * Flag to prevent endless validation loop, if this object is referenced
      87:      * by another object which falls in this transaction.
      88:      * @var        boolean
      89:      */
      90:     protected $alreadyInValidation = false;
      91:
      92:     /**
      93:      * Applies default values to this object.
      94:      * This method should be called from the object's constructor (or
      95:      * equivalent initialization method).
      96:      * @see        __construct()
      97:      */
      98:     public function applyDefaultValues()
      99:     {
     100:         $this->locale = 'en_EN';
     101:     }
     102:
     103:     /**
     104:      * Initializes internal state of BaseCustomerTitleI18n object.
     105:      * @see        applyDefaults()
     106:      */
     107:     public function __construct()
     108:     {
     109:         parent::__construct();
     110:         $this->applyDefaultValues();
     111:     }
     112:
     113:     /**
     114:      * Get the [id] column value.
     115:      *
     116:      * @return int
     117:      */
     118:     public function getId()
     119:     {
     120:         return $this->id;
     121:     }
     122:
     123:     /**
     124:      * Get the [locale] column value.
     125:      *
     126:      * @return string
     127:      */
     128:     public function getLocale()
     129:     {
     130:         return $this->locale;
     131:     }
     132:
     133:     /**
     134:      * Get the [short] column value.
     135:      *
     136:      * @return string
     137:      */
     138:     public function getShort()
     139:     {
     140:         return $this->short;
     141:     }
     142:
     143:     /**
     144:      * Get the [long] column value.
     145:      *
     146:      * @return string
     147:      */
     148:     public function getLong()
     149:     {
     150:         return $this->long;
     151:     }
     152:
     153:     /**
     154:      * Set the value of [id] column.
     155:      *
     156:      * @param int $v new value
     157:      * @return CustomerTitleI18n The current object (for fluent API support)
     158:      */
     159:     public function setId($v)
     160:     {
     161:         if ($v !== null) {
     162:             $v = (int) $v;
     163:         }
     164:
     165:         if ($this->id !== $v) {
     166:             $this->id = $v;
     167:             $this->modifiedColumns[] = CustomerTitleI18nPeer::ID;
     168:         }
     169:
     170:         if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
     171:             $this->aCustomerTitle = null;
     172:         }
     173:
     174:
     175:         return $this;
     176:     } // setId()
     177:
     178:     /**
     179:      * Set the value of [locale] column.
     180:      *
     181:      * @param string $v new value
     182:      * @return CustomerTitleI18n The current object (for fluent API support)
     183:      */
     184:     public function setLocale($v)
     185:     {
     186:         if ($v !== null) {
     187:             $v = (string) $v;
     188:         }
     189:
     190:         if ($this->locale !== $v) {
     191:             $this->locale = $v;
     192:             $this->modifiedColumns[] = CustomerTitleI18nPeer::LOCALE;
     193:         }
     194:
     195:
     196:         return $this;
     197:     } // setLocale()
     198:
     199:     /**
     200:      * Set the value of [short] column.
     201:      *
     202:      * @param string $v new value
     203:      * @return CustomerTitleI18n The current object (for fluent API support)
     204:      */
     205:     public function setShort($v)
     206:     {
     207:         if ($v !== null) {
     208:             $v = (string) $v;
     209:         }
     210:
     211:         if ($this->short !== $v) {
     212:             $this->short = $v;
     213:             $this->modifiedColumns[] = CustomerTitleI18nPeer::SHORT;
     214:         }
     215:
     216:
     217:         return $this;
     218:     } // setShort()
     219:
     220:     /**
     221:      * Set the value of [long] column.
     222:      *
     223:      * @param string $v new value
     224:      * @return CustomerTitleI18n The current object (for fluent API support)
     225:      */
     226:     public function setLong($v)
     227:     {
     228:         if ($v !== null) {
     229:             $v = (string) $v;
     230:         }
     231:
     232:         if ($this->long !== $v) {
     233:             $this->long = $v;
     234:             $this->modifiedColumns[] = CustomerTitleI18nPeer::LONG;
     235:         }
     236:
     237:
     238:         return $this;
     239:     } // setLong()
     240:
     241:     /**
     242:      * Indicates whether the columns in this object are only set to default values.
     243:      *
     244:      * This method can be used in conjunction with isModified() to indicate whether an object is both
     245:      * modified _and_ has some values set which are non-default.
     246:      *
     247:      * @return boolean Whether the columns in this object are only been set with default values.
     248:      */
     249:     public function hasOnlyDefaultValues()
     250:     {
     251:             if ($this->locale !== 'en_EN') {
     252:                 return false;
     253:             }
     254:
     255:         // otherwise, everything was equal, so return true
     256:         return true;
     257:     } // hasOnlyDefaultValues()
     258:
     259:     /**
     260:      * Hydrates (populates) the object variables with values from the database resultset.
     261:      *
     262:      * An offset (0-based "start column") is specified so that objects can be hydrated
     263:      * with a subset of the columns in the resultset rows.  This is needed, for example,
     264:      * for results of JOIN queries where the resultset row includes columns from two or
     265:      * more tables.
     266:      *
     267:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     268:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     269:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     270:      * @return int             next starting column
     271:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     272:      */
     273:     public function hydrate($row, $startcol = 0, $rehydrate = false)
     274:     {
     275:         try {
     276:
     277:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
     278:             $this->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
     279:             $this->short = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
     280:             $this->long = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
     281:             $this->resetModified();
     282:
     283:             $this->setNew(false);
     284:
     285:             if ($rehydrate) {
     286:                 $this->ensureConsistency();
     287:             }
     288:
     289:             return $startcol + 4; // 4 = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS.
     290:
     291:         } catch (Exception $e) {
     292:             throw new PropelException("Error populating CustomerTitleI18n object", $e);
     293:         }
     294:     }
     295:
     296:     /**
     297:      * Checks and repairs the internal consistency of the object.
     298:      *
     299:      * This method is executed after an already-instantiated object is re-hydrated
     300:      * from the database.  It exists to check any foreign keys to make sure that
     301:      * the objects related to the current object are correct based on foreign key.
     302:      *
     303:      * You can override this method in the stub class, but you should always invoke
     304:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
     305:      * in case your model changes.
     306:      *
     307:      * @throws PropelException
     308:      */
     309:     public function ensureConsistency()
     310:     {
     311:
     312:         if ($this->aCustomerTitle !== null && $this->id !== $this->aCustomerTitle->getId()) {
     313:             $this->aCustomerTitle = null;
     314:         }
     315:     } // ensureConsistency
     316:
     317:     /**
     318:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     319:      *
     320:      * This will only work if the object has been saved and has a valid primary key set.
     321:      *
     322:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
     323:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
     324:      * @return void
     325:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     326:      */
     327:     public function reload($deep = false, PropelPDO $con = null)
     328:     {
     329:         if ($this->isDeleted()) {
     330:             throw new PropelException("Cannot reload a deleted object.");
     331:         }
     332:
     333:         if ($this->isNew()) {
     334:             throw new PropelException("Cannot reload an unsaved object.");
     335:         }
     336:
     337:         if ($con === null) {
     338:             $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     339:         }
     340:
     341:         // We don't need to alter the object instance pool; we're just modifying this instance
     342:         // already in the pool.
     343:
     344:         $stmt = CustomerTitleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
     345:         $row = $stmt->fetch(PDO::FETCH_NUM);
     346:         $stmt->closeCursor();
     347:         if (!$row) {
     348:             throw new PropelException('Cannot find matching row in the database to reload object values.');
     349:         }
     350:         $this->hydrate($row, 0, true); // rehydrate
     351:
     352:         if ($deep) {  // also de-associate any related objects?
     353:
     354:             $this->aCustomerTitle = null;
     355:         } // if (deep)
     356:     }
     357:
     358:     /**
     359:      * Removes this object from datastore and sets delete attribute.
     360:      *
     361:      * @param PropelPDO $con
     362:      * @return void
     363:      * @throws PropelException
     364:      * @throws Exception
     365:      * @see        BaseObject::setDeleted()
     366:      * @see        BaseObject::isDeleted()
     367:      */
     368:     public function delete(PropelPDO $con = null)
     369:     {
     370:         if ($this->isDeleted()) {
     371:             throw new PropelException("This object has already been deleted.");
     372:         }
     373:
     374:         if ($con === null) {
     375:             $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     376:         }
     377:
     378:         $con->beginTransaction();
     379:         try {
     380:             $deleteQuery = CustomerTitleI18nQuery::create()
     381:                 ->filterByPrimaryKey($this->getPrimaryKey());
     382:             $ret = $this->preDelete($con);
     383:             if ($ret) {
     384:                 $deleteQuery->delete($con);
     385:                 $this->postDelete($con);
     386:                 $con->commit();
     387:                 $this->setDeleted(true);
     388:             } else {
     389:                 $con->commit();
     390:             }
     391:         } catch (Exception $e) {
     392:             $con->rollBack();
     393:             throw $e;
     394:         }
     395:     }
     396:
     397:     /**
     398:      * Persists this object to the database.
     399:      *
     400:      * If the object is new, it inserts it; otherwise an update is performed.
     401:      * All modified related objects will also be persisted in the doSave()
     402:      * method.  This method wraps all precipitate database operations in a
     403:      * single transaction.
     404:      *
     405:      * @param PropelPDO $con
     406:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     407:      * @throws PropelException
     408:      * @throws Exception
     409:      * @see        doSave()
     410:      */
     411:     public function save(PropelPDO $con = null)
     412:     {
     413:         if ($this->isDeleted()) {
     414:             throw new PropelException("You cannot save an object that has been deleted.");
     415:         }
     416:
     417:         if ($con === null) {
     418:             $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     419:         }
     420:
     421:         $con->beginTransaction();
     422:         $isInsert = $this->isNew();
     423:         try {
     424:             $ret = $this->preSave($con);
     425:             if ($isInsert) {
     426:                 $ret = $ret && $this->preInsert($con);
     427:             } else {
     428:                 $ret = $ret && $this->preUpdate($con);
     429:             }
     430:             if ($ret) {
     431:                 $affectedRows = $this->doSave($con);
     432:                 if ($isInsert) {
     433:                     $this->postInsert($con);
     434:                 } else {
     435:                     $this->postUpdate($con);
     436:                 }
     437:                 $this->postSave($con);
     438:                 CustomerTitleI18nPeer::addInstanceToPool($this);
     439:             } else {
     440:                 $affectedRows = 0;
     441:             }
     442:             $con->commit();
     443:
     444:             return $affectedRows;
     445:         } catch (Exception $e) {
     446:             $con->rollBack();
     447:             throw $e;
     448:         }
     449:     }
     450:
     451:     /**
     452:      * Performs the work of inserting or updating the row in the database.
     453:      *
     454:      * If the object is new, it inserts it; otherwise an update is performed.
     455:      * All related objects are also updated in this method.
     456:      *
     457:      * @param PropelPDO $con
     458:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     459:      * @throws PropelException
     460:      * @see        save()
     461:      */
     462:     protected function doSave(PropelPDO $con)
     463:     {
     464:         $affectedRows = 0; // initialize var to track total num of affected rows
     465:         if (!$this->alreadyInSave) {
     466:             $this->alreadyInSave = true;
     467:
     468:             // We call the save method on the following object(s) if they
     469:             // were passed to this object by their coresponding set
     470:             // method.  This object relates to these object(s) by a
     471:             // foreign key reference.
     472:
     473:             if ($this->aCustomerTitle !== null) {
     474:                 if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
     475:                     $affectedRows += $this->aCustomerTitle->save($con);
     476:                 }
     477:                 $this->setCustomerTitle($this->aCustomerTitle);
     478:             }
     479:
     480:             if ($this->isNew() || $this->isModified()) {
     481:                 // persist changes
     482:                 if ($this->isNew()) {
     483:                     $this->doInsert($con);
     484:                 } else {
     485:                     $this->doUpdate($con);
     486:                 }
     487:                 $affectedRows += 1;
     488:                 $this->resetModified();
     489:             }
     490:
     491:             $this->alreadyInSave = false;
     492:
     493:         }
     494:
     495:         return $affectedRows;
     496:     } // doSave()
     497:
     498:     /**
     499:      * Insert the row in the database.
     500:      *
     501:      * @param PropelPDO $con
     502:      *
     503:      * @throws PropelException
     504:      * @see        doSave()
     505:      */
     506:     protected function doInsert(PropelPDO $con)
     507:     {
     508:         $modifiedColumns = array();
     509:         $index = 0;
     510:
     511:
     512:          // check the columns in natural order for more readable SQL queries
     513:         if ($this->isColumnModified(CustomerTitleI18nPeer::ID)) {
     514:             $modifiedColumns[':p' . $index++]  = '`ID`';
     515:         }
     516:         if ($this->isColumnModified(CustomerTitleI18nPeer::LOCALE)) {
     517:             $modifiedColumns[':p' . $index++]  = '`LOCALE`';
     518:         }
     519:         if ($this->isColumnModified(CustomerTitleI18nPeer::SHORT)) {
     520:             $modifiedColumns[':p' . $index++]  = '`SHORT`';
     521:         }
     522:         if ($this->isColumnModified(CustomerTitleI18nPeer::LONG)) {
     523:             $modifiedColumns[':p' . $index++]  = '`LONG`';
     524:         }
     525:
     526:         $sql = sprintf(
     527:             'INSERT INTO `customer_title_i18n` (%s) VALUES (%s)',
     528:             implode(', ', $modifiedColumns),
     529:             implode(', ', array_keys($modifiedColumns))
     530:         );
     531:
     532:         try {
     533:             $stmt = $con->prepare($sql);
     534:             foreach ($modifiedColumns as $identifier => $columnName) {
     535:                 switch ($columnName) {
     536:                     case '`ID`':
     537:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
     538:                         break;
     539:                     case '`LOCALE`':
     540:                         $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
     541:                         break;
     542:                     case '`SHORT`':
     543:                         $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR);
     544:                         break;
     545:                     case '`LONG`':
     546:                         $stmt->bindValue($identifier, $this->long, PDO::PARAM_STR);
     547:                         break;
     548:                 }
     549:             }
     550:             $stmt->execute();
     551:         } catch (Exception $e) {
     552:             Propel::log($e->getMessage(), Propel::LOG_ERR);
     553:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     554:         }
     555:
     556:         $this->setNew(false);
     557:     }
     558:
     559:     /**
     560:      * Update the row in the database.
     561:      *
     562:      * @param PropelPDO $con
     563:      *
     564:      * @see        doSave()
     565:      */
     566:     protected function doUpdate(PropelPDO $con)
     567:     {
     568:         $selectCriteria = $this->buildPkeyCriteria();
     569:         $valuesCriteria = $this->buildCriteria();
     570:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
     571:     }
     572:
     573:     /**
     574:      * Array of ValidationFailed objects.
     575:      * @var        array ValidationFailed[]
     576:      */
     577:     protected $validationFailures = array();
     578:
     579:     /**
     580:      * Gets any ValidationFailed objects that resulted from last call to validate().
     581:      *
     582:      *
     583:      * @return array ValidationFailed[]
     584:      * @see        validate()
     585:      */
     586:     public function getValidationFailures()
     587:     {
     588:         return $this->validationFailures;
     589:     }
     590:
     591:     /**
     592:      * Validates the objects modified field values and all objects related to this table.
     593:      *
     594:      * If $columns is either a column name or an array of column names
     595:      * only those columns are validated.
     596:      *
     597:      * @param mixed $columns Column name or an array of column names.
     598:      * @return boolean Whether all columns pass validation.
     599:      * @see        doValidate()
     600:      * @see        getValidationFailures()
     601:      */
     602:     public function validate($columns = null)
     603:     {
     604:         $res = $this->doValidate($columns);
     605:         if ($res === true) {
     606:             $this->validationFailures = array();
     607:
     608:             return true;
     609:         } else {
     610:             $this->validationFailures = $res;
     611:
     612:             return false;
     613:         }
     614:     }
     615:
     616:     /**
     617:      * This function performs the validation work for complex object models.
     618:      *
     619:      * In addition to checking the current object, all related objects will
     620:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
     621:      * an aggreagated array of ValidationFailed objects will be returned.
     622:      *
     623:      * @param array $columns Array of column names to validate.
     624:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     625:      */
     626:     protected function doValidate($columns = null)
     627:     {
     628:         if (!$this->alreadyInValidation) {
     629:             $this->alreadyInValidation = true;
     630:             $retval = null;
     631:
     632:             $failureMap = array();
     633:
     634:
     635:             // We call the validate method on the following object(s) if they
     636:             // were passed to this object by their coresponding set
     637:             // method.  This object relates to these object(s) by a
     638:             // foreign key reference.
     639:
     640:             if ($this->aCustomerTitle !== null) {
     641:                 if (!$this->aCustomerTitle->validate($columns)) {
     642:                     $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures());
     643:                 }
     644:             }
     645:
     646:
     647:             if (($retval = CustomerTitleI18nPeer::doValidate($this, $columns)) !== true) {
     648:                 $failureMap = array_merge($failureMap, $retval);
     649:             }
     650:
     651:
     652:
     653:             $this->alreadyInValidation = false;
     654:         }
     655:
     656:         return (!empty($failureMap) ? $failureMap : true);
     657:     }
     658:
     659:     /**
     660:      * Retrieves a field from the object by name passed in as a string.
     661:      *
     662:      * @param string $name name
     663:      * @param string $type The type of fieldname the $name is of:
     664:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     665:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     666:      *               Defaults to BasePeer::TYPE_PHPNAME
     667:      * @return mixed Value of field.
     668:      */
     669:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
     670:     {
     671:         $pos = CustomerTitleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     672:         $field = $this->getByPosition($pos);
     673:
     674:         return $field;
     675:     }
     676:
     677:     /**
     678:      * Retrieves a field from the object by Position as specified in the xml schema.
     679:      * Zero-based.
     680:      *
     681:      * @param int $pos position in xml schema
     682:      * @return mixed Value of field at $pos
     683:      */
     684:     public function getByPosition($pos)
     685:     {
     686:         switch ($pos) {
     687:             case 0:
     688:                 return $this->getId();
     689:                 break;
     690:             case 1:
     691:                 return $this->getLocale();
     692:                 break;
     693:             case 2:
     694:                 return $this->getShort();
     695:                 break;
     696:             case 3:
     697:                 return $this->getLong();
     698:                 break;
     699:             default:
     700:                 return null;
     701:                 break;
     702:         } // switch()
     703:     }
     704:
     705:     /**
     706:      * Exports the object as an array.
     707:      *
     708:      * You can specify the key type of the array by passing one of the class
     709:      * type constants.
     710:      *
     711:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     712:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     713:      *                    Defaults to BasePeer::TYPE_PHPNAME.
     714:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     715:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     716:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     717:      *
     718:      * @return array an associative array containing the field names (as keys) and field values
     719:      */
     720:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
     721:     {
     722:         if (isset($alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())])) {
     723:             return '*RECURSION*';
     724:         }
     725:         $alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())] = true;
     726:         $keys = CustomerTitleI18nPeer::getFieldNames($keyType);
     727:         $result = array(
     728:             $keys[0] => $this->getId(),
     729:             $keys[1] => $this->getLocale(),
     730:             $keys[2] => $this->getShort(),
     731:             $keys[3] => $this->getLong(),
     732:         );
     733:         if ($includeForeignObjects) {
     734:             if (null !== $this->aCustomerTitle) {
     735:                 $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
     736:             }
     737:         }
     738:
     739:         return $result;
     740:     }
     741:
     742:     /**
     743:      * Sets a field from the object by name passed in as a string.
     744:      *
     745:      * @param string $name peer name
     746:      * @param mixed $value field value
     747:      * @param string $type The type of fieldname the $name is of:
     748:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     749:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     750:      *                     Defaults to BasePeer::TYPE_PHPNAME
     751:      * @return void
     752:      */
     753:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
     754:     {
     755:         $pos = CustomerTitleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     756:
     757:         $this->setByPosition($pos, $value);
     758:     }
     759:
     760:     /**
     761:      * Sets a field from the object by Position as specified in the xml schema.
     762:      * Zero-based.
     763:      *
     764:      * @param int $pos position in xml schema
     765:      * @param mixed $value field value
     766:      * @return void
     767:      */
     768:     public function setByPosition($pos, $value)
     769:     {
     770:         switch ($pos) {
     771:             case 0:
     772:                 $this->setId($value);
     773:                 break;
     774:             case 1:
     775:                 $this->setLocale($value);
     776:                 break;
     777:             case 2:
     778:                 $this->setShort($value);
     779:                 break;
     780:             case 3:
     781:                 $this->setLong($value);
     782:                 break;
     783:         } // switch()
     784:     }
     785:
     786:     /**
     787:      * Populates the object using an array.
     788:      *
     789:      * This is particularly useful when populating an object from one of the
     790:      * request arrays (e.g. $_POST).  This method goes through the column
     791:      * names, checking to see whether a matching key exists in populated
     792:      * array. If so the setByName() method is called for that column.
     793:      *
     794:      * You can specify the key type of the array by additionally passing one
     795:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     796:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     797:      * The default key type is the column's BasePeer::TYPE_PHPNAME
     798:      *
     799:      * @param array  $arr     An array to populate the object from.
     800:      * @param string $keyType The type of keys the array uses.
     801:      * @return void
     802:      */
     803:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
     804:     {
     805:         $keys = CustomerTitleI18nPeer::getFieldNames($keyType);
     806:
     807:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
     808:         if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
     809:         if (array_key_exists($keys[2], $arr)) $this->setShort($arr[$keys[2]]);
     810:         if (array_key_exists($keys[3], $arr)) $this->setLong($arr[$keys[3]]);
     811:     }
     812:
     813:     /**
     814:      * Build a Criteria object containing the values of all modified columns in this object.
     815:      *
     816:      * @return Criteria The Criteria object containing all modified values.
     817:      */
     818:     public function buildCriteria()
     819:     {
     820:         $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME);
     821:
     822:         if ($this->isColumnModified(CustomerTitleI18nPeer::ID)) $criteria->add(CustomerTitleI18nPeer::ID, $this->id);
     823:         if ($this->isColumnModified(CustomerTitleI18nPeer::LOCALE)) $criteria->add(CustomerTitleI18nPeer::LOCALE, $this->locale);
     824:         if ($this->isColumnModified(CustomerTitleI18nPeer::SHORT)) $criteria->add(CustomerTitleI18nPeer::SHORT, $this->short);
     825:         if ($this->isColumnModified(CustomerTitleI18nPeer::LONG)) $criteria->add(CustomerTitleI18nPeer::LONG, $this->long);
     826:
     827:         return $criteria;
     828:     }
     829:
     830:     /**
     831:      * Builds a Criteria object containing the primary key for this object.
     832:      *
     833:      * Unlike buildCriteria() this method includes the primary key values regardless
     834:      * of whether or not they have been modified.
     835:      *
     836:      * @return Criteria The Criteria object containing value(s) for primary key(s).
     837:      */
     838:     public function buildPkeyCriteria()
     839:     {
     840:         $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME);
     841:         $criteria->add(CustomerTitleI18nPeer::ID, $this->id);
     842:         $criteria->add(CustomerTitleI18nPeer::LOCALE, $this->locale);
     843:
     844:         return $criteria;
     845:     }
     846:
     847:     /**
     848:      * Returns the composite primary key for this object.
     849:      * The array elements will be in same order as specified in XML.
     850:      * @return array
     851:      */
     852:     public function getPrimaryKey()
     853:     {
     854:         $pks = array();
     855:         $pks[0] = $this->getId();
     856:         $pks[1] = $this->getLocale();
     857:
     858:         return $pks;
     859:     }
     860:
     861:     /**
     862:      * Set the [composite] primary key.
     863:      *
     864:      * @param array $keys The elements of the composite key (order must match the order in XML file).
     865:      * @return void
     866:      */
     867:     public function setPrimaryKey($keys)
     868:     {
     869:         $this->setId($keys[0]);
     870:         $this->setLocale($keys[1]);
     871:     }
     872:
     873:     /**
     874:      * Returns true if the primary key for this object is null.
     875:      * @return boolean
     876:      */
     877:     public function isPrimaryKeyNull()
     878:     {
     879:
     880:         return (null === $this->getId()) && (null === $this->getLocale());
     881:     }
     882:
     883:     /**
     884:      * Sets contents of passed object to values from current object.
     885:      *
     886:      * If desired, this method can also make copies of all associated (fkey referrers)
     887:      * objects.
     888:      *
     889:      * @param object $copyObj An object of CustomerTitleI18n (or compatible) type.
     890:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     891:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
     892:      * @throws PropelException
     893:      */
     894:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
     895:     {
     896:         $copyObj->setId($this->getId());
     897:         $copyObj->setLocale($this->getLocale());
     898:         $copyObj->setShort($this->getShort());
     899:         $copyObj->setLong($this->getLong());
     900:
     901:         if ($deepCopy && !$this->startCopy) {
     902:             // important: temporarily setNew(false) because this affects the behavior of
     903:             // the getter/setter methods for fkey referrer objects.
     904:             $copyObj->setNew(false);
     905:             // store object hash to prevent cycle
     906:             $this->startCopy = true;
     907:
     908:             //unflag object copy
     909:             $this->startCopy = false;
     910:         } // if ($deepCopy)
     911:
     912:         if ($makeNew) {
     913:             $copyObj->setNew(true);
     914:         }
     915:     }
     916:
     917:     /**
     918:      * Makes a copy of this object that will be inserted as a new row in table when saved.
     919:      * It creates a new object filling in the simple attributes, but skipping any primary
     920:      * keys that are defined for the table.
     921:      *
     922:      * If desired, this method can also make copies of all associated (fkey referrers)
     923:      * objects.
     924:      *
     925:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
     926:      * @return CustomerTitleI18n Clone of current object.
     927:      * @throws PropelException
     928:      */
     929:     public function copy($deepCopy = false)
     930:     {
     931:         // we use get_class(), because this might be a subclass
     932:         $clazz = get_class($this);
     933:         $copyObj = new $clazz();
     934:         $this->copyInto($copyObj, $deepCopy);
     935:
     936:         return $copyObj;
     937:     }
     938:
     939:     /**
     940:      * Returns a peer instance associated with this om.
     941:      *
     942:      * Since Peer classes are not to have any instance attributes, this method returns the
     943:      * same instance for all member of this class. The method could therefore
     944:      * be static, but this would prevent one from overriding the behavior.
     945:      *
     946:      * @return CustomerTitleI18nPeer
     947:      */
     948:     public function getPeer()
     949:     {
     950:         if (self::$peer === null) {
     951:             self::$peer = new CustomerTitleI18nPeer();
     952:         }
     953:
     954:         return self::$peer;
     955:     }
     956:
     957:     /**
     958:      * Declares an association between this object and a CustomerTitle object.
     959:      *
     960:      * @param             CustomerTitle $v
     961:      * @return CustomerTitleI18n The current object (for fluent API support)
     962:      * @throws PropelException
     963:      */
     964:     public function setCustomerTitle(CustomerTitle $v = null)
     965:     {
     966:         if ($v === null) {
     967:             $this->setId(NULL);
     968:         } else {
     969:             $this->setId($v->getId());
     970:         }
     971:
     972:         $this->aCustomerTitle = $v;
     973:
     974:         // Add binding for other direction of this n:n relationship.
     975:         // If this object has already been added to the CustomerTitle object, it will not be re-added.
     976:         if ($v !== null) {
     977:             $v->addCustomerTitleI18n($this);
     978:         }
     979:
     980:
     981:         return $this;
     982:     }
     983:
     984:
     985:     /**
     986:      * Get the associated CustomerTitle object
     987:      *
     988:      * @param PropelPDO $con Optional Connection object.
     989:      * @return CustomerTitle The associated CustomerTitle object.
     990:      * @throws PropelException
     991:      */
     992:     public function getCustomerTitle(PropelPDO $con = null)
     993:     {
     994:         if ($this->aCustomerTitle === null && ($this->id !== null)) {
     995:             $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->id, $con);
     996:             /* The following can be used additionally to
     997:                 guarantee the related object contains a reference
     998:                 to this object.  This level of coupling may, however, be
     999:                 undesirable since it could result in an only partially populated collection
    1000:                 in the referenced object.
    1001:                 $this->aCustomerTitle->addCustomerTitleI18ns($this);
    1002:              */
    1003:         }
    1004:
    1005:         return $this->aCustomerTitle;
    1006:     }
    1007:
    1008:     /**
    1009:      * Clears the current object and sets all attributes to their default values
    1010:      */
    1011:     public function clear()
    1012:     {
    1013:         $this->id = null;
    1014:         $this->locale = null;
    1015:         $this->short = null;
    1016:         $this->long = null;
    1017:         $this->alreadyInSave = false;
    1018:         $this->alreadyInValidation = false;
    1019:         $this->clearAllReferences();
    1020:         $this->applyDefaultValues();
    1021:         $this->resetModified();
    1022:         $this->setNew(true);
    1023:         $this->setDeleted(false);
    1024:     }
    1025:
    1026:     /**
    1027:      * Resets all references to other model objects or collections of model objects.
    1028:      *
    1029:      * This method is a user-space workaround for PHP's inability to garbage collect
    1030:      * objects with circular references (even in PHP 5.3). This is currently necessary
    1031:      * when using Propel in certain daemon or large-volumne/high-memory operations.
    1032:      *
    1033:      * @param boolean $deep Whether to also clear the references on all referrer objects.
    1034:      */
    1035:     public function clearAllReferences($deep = false)
    1036:     {
    1037:         if ($deep) {
    1038:         } // if ($deep)
    1039:
    1040:         $this->aCustomerTitle = null;
    1041:     }
    1042:
    1043:     /**
    1044:      * return the string representation of this object
    1045:      *
    1046:      * @return string
    1047:      */
    1048:     public function __toString()
    1049:     {
    1050:         return (string) $this->exportTo(CustomerTitleI18nPeer::DEFAULT_STRING_FORMAT);
    1051:     }
    1052:
    1053:     /**
    1054:      * return true is the object is in saving state
    1055:      *
    1056:      * @return boolean
    1057:      */
    1058:     public function isAlreadyInSave()
    1059:     {
    1060:         return $this->alreadyInSave;
    1061:     }
    1062:
    1063: }
    1064: