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