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

       1: <?php
       2:
       3: namespace Thelia\Model\om;
       4:
       5: use \BaseObject;
       6: use \BasePeer;
       7: use \Criteria;
       8: use \DateTime;
       9: use \Exception;
      10: use \PDO;
      11: use \Persistent;
      12: use \Propel;
      13: use \PropelCollection;
      14: use \PropelDateTime;
      15: use \PropelException;
      16: use \PropelObjectCollection;
      17: use \PropelPDO;
      18: use Thelia\Model\Feature;
      19: use Thelia\Model\FeatureAv;
      20: use Thelia\Model\FeatureAvQuery;
      21: use Thelia\Model\FeatureCategory;
      22: use Thelia\Model\FeatureCategoryQuery;
      23: use Thelia\Model\FeatureI18n;
      24: use Thelia\Model\FeatureI18nQuery;
      25: use Thelia\Model\FeaturePeer;
      26: use Thelia\Model\FeatureProd;
      27: use Thelia\Model\FeatureProdQuery;
      28: use Thelia\Model\FeatureQuery;
      29:
      30: /**
      31:  * Base class that represents a row from the 'feature' table.
      32:  *
      33:  *
      34:  *
      35:  * @package    propel.generator.Thelia.Model.om
      36:  */
      37: abstract class BaseFeature extends BaseObject implements Persistent
      38: {
      39:     /**
      40:      * Peer class name
      41:      */
      42:     const PEER = 'Thelia\\Model\\FeaturePeer';
      43:
      44:     /**
      45:      * The Peer class.
      46:      * Instance provides a convenient way of calling static methods on a class
      47:      * that calling code may not be able to identify.
      48:      * @var        FeaturePeer
      49:      */
      50:     protected static $peer;
      51:
      52:     /**
      53:      * The flag var to prevent infinit loop in deep copy
      54:      * @var       boolean
      55:      */
      56:     protected $startCopy = false;
      57:
      58:     /**
      59:      * The value for the id field.
      60:      * @var        int
      61:      */
      62:     protected $id;
      63:
      64:     /**
      65:      * The value for the visible field.
      66:      * Note: this column has a database default value of: 0
      67:      * @var        int
      68:      */
      69:     protected $visible;
      70:
      71:     /**
      72:      * The value for the position field.
      73:      * @var        int
      74:      */
      75:     protected $position;
      76:
      77:     /**
      78:      * The value for the created_at field.
      79:      * @var        string
      80:      */
      81:     protected $created_at;
      82:
      83:     /**
      84:      * The value for the updated_at field.
      85:      * @var        string
      86:      */
      87:     protected $updated_at;
      88:
      89:     /**
      90:      * @var        PropelObjectCollection|FeatureAv[] Collection to store aggregation of FeatureAv objects.
      91:      */
      92:     protected $collFeatureAvs;
      93:     protected $collFeatureAvsPartial;
      94:
      95:     /**
      96:      * @var        PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects.
      97:      */
      98:     protected $collFeatureProds;
      99:     protected $collFeatureProdsPartial;
     100:
     101:     /**
     102:      * @var        PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects.
     103:      */
     104:     protected $collFeatureCategorys;
     105:     protected $collFeatureCategorysPartial;
     106:
     107:     /**
     108:      * @var        PropelObjectCollection|FeatureI18n[] Collection to store aggregation of FeatureI18n objects.
     109:      */
     110:     protected $collFeatureI18ns;
     111:     protected $collFeatureI18nsPartial;
     112:
     113:     /**
     114:      * Flag to prevent endless save loop, if this object is referenced
     115:      * by another object which falls in this transaction.
     116:      * @var        boolean
     117:      */
     118:     protected $alreadyInSave = false;
     119:
     120:     /**
     121:      * Flag to prevent endless validation loop, if this object is referenced
     122:      * by another object which falls in this transaction.
     123:      * @var        boolean
     124:      */
     125:     protected $alreadyInValidation = false;
     126:
     127:     // i18n behavior
     128:
     129:     /**
     130:      * Current locale
     131:      * @var        string
     132:      */
     133:     protected $currentLocale = 'en_EN';
     134:
     135:     /**
     136:      * Current translation objects
     137:      * @var        array[FeatureI18n]
     138:      */
     139:     protected $currentTranslations;
     140:
     141:     /**
     142:      * An array of objects scheduled for deletion.
     143:      * @var     PropelObjectCollection
     144:      */
     145:     protected $featureAvsScheduledForDeletion = null;
     146:
     147:     /**
     148:      * An array of objects scheduled for deletion.
     149:      * @var     PropelObjectCollection
     150:      */
     151:     protected $featureProdsScheduledForDeletion = null;
     152:
     153:     /**
     154:      * An array of objects scheduled for deletion.
     155:      * @var     PropelObjectCollection
     156:      */
     157:     protected $featureCategorysScheduledForDeletion = null;
     158:
     159:     /**
     160:      * An array of objects scheduled for deletion.
     161:      * @var     PropelObjectCollection
     162:      */
     163:     protected $featureI18nsScheduledForDeletion = null;
     164:
     165:     /**
     166:      * Applies default values to this object.
     167:      * This method should be called from the object's constructor (or
     168:      * equivalent initialization method).
     169:      * @see        __construct()
     170:      */
     171:     public function applyDefaultValues()
     172:     {
     173:         $this->visible = 0;
     174:     }
     175:
     176:     /**
     177:      * Initializes internal state of BaseFeature object.
     178:      * @see        applyDefaults()
     179:      */
     180:     public function __construct()
     181:     {
     182:         parent::__construct();
     183:         $this->applyDefaultValues();
     184:     }
     185:
     186:     /**
     187:      * Get the [id] column value.
     188:      *
     189:      * @return int
     190:      */
     191:     public function getId()
     192:     {
     193:         return $this->id;
     194:     }
     195:
     196:     /**
     197:      * Get the [visible] column value.
     198:      *
     199:      * @return int
     200:      */
     201:     public function getVisible()
     202:     {
     203:         return $this->visible;
     204:     }
     205:
     206:     /**
     207:      * Get the [position] column value.
     208:      *
     209:      * @return int
     210:      */
     211:     public function getPosition()
     212:     {
     213:         return $this->position;
     214:     }
     215:
     216:     /**
     217:      * Get the [optionally formatted] temporal [created_at] column value.
     218:      *
     219:      *
     220:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     221:      *               If format is null, then the raw DateTime object will be returned.
     222:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     223:      * @throws PropelException - if unable to parse/validate the date/time value.
     224:      */
     225:     public function getCreatedAt($format = 'Y-m-d H:i:s')
     226:     {
     227:         if ($this->created_at === null) {
     228:             return null;
     229:         }
     230:
     231:         if ($this->created_at === '0000-00-00 00:00:00') {
     232:             // while technically this is not a default value of null,
     233:             // this seems to be closest in meaning.
     234:             return null;
     235:         } else {
     236:             try {
     237:                 $dt = new DateTime($this->created_at);
     238:             } catch (Exception $x) {
     239:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
     240:             }
     241:         }
     242:
     243:         if ($format === null) {
     244:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     245:             return $dt;
     246:         } elseif (strpos($format, '%') !== false) {
     247:             return strftime($format, $dt->format('U'));
     248:         } else {
     249:             return $dt->format($format);
     250:         }
     251:     }
     252:
     253:     /**
     254:      * Get the [optionally formatted] temporal [updated_at] column value.
     255:      *
     256:      *
     257:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     258:      *               If format is null, then the raw DateTime object will be returned.
     259:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     260:      * @throws PropelException - if unable to parse/validate the date/time value.
     261:      */
     262:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
     263:     {
     264:         if ($this->updated_at === null) {
     265:             return null;
     266:         }
     267:
     268:         if ($this->updated_at === '0000-00-00 00:00:00') {
     269:             // while technically this is not a default value of null,
     270:             // this seems to be closest in meaning.
     271:             return null;
     272:         } else {
     273:             try {
     274:                 $dt = new DateTime($this->updated_at);
     275:             } catch (Exception $x) {
     276:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
     277:             }
     278:         }
     279:
     280:         if ($format === null) {
     281:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     282:             return $dt;
     283:         } elseif (strpos($format, '%') !== false) {
     284:             return strftime($format, $dt->format('U'));
     285:         } else {
     286:             return $dt->format($format);
     287:         }
     288:     }
     289:
     290:     /**
     291:      * Set the value of [id] column.
     292:      *
     293:      * @param int $v new value
     294:      * @return Feature The current object (for fluent API support)
     295:      */
     296:     public function setId($v)
     297:     {
     298:         if ($v !== null) {
     299:             $v = (int) $v;
     300:         }
     301:
     302:         if ($this->id !== $v) {
     303:             $this->id = $v;
     304:             $this->modifiedColumns[] = FeaturePeer::ID;
     305:         }
     306:
     307:
     308:         return $this;
     309:     } // setId()
     310:
     311:     /**
     312:      * Set the value of [visible] column.
     313:      *
     314:      * @param int $v new value
     315:      * @return Feature The current object (for fluent API support)
     316:      */
     317:     public function setVisible($v)
     318:     {
     319:         if ($v !== null) {
     320:             $v = (int) $v;
     321:         }
     322:
     323:         if ($this->visible !== $v) {
     324:             $this->visible = $v;
     325:             $this->modifiedColumns[] = FeaturePeer::VISIBLE;
     326:         }
     327:
     328:
     329:         return $this;
     330:     } // setVisible()
     331:
     332:     /**
     333:      * Set the value of [position] column.
     334:      *
     335:      * @param int $v new value
     336:      * @return Feature The current object (for fluent API support)
     337:      */
     338:     public function setPosition($v)
     339:     {
     340:         if ($v !== null) {
     341:             $v = (int) $v;
     342:         }
     343:
     344:         if ($this->position !== $v) {
     345:             $this->position = $v;
     346:             $this->modifiedColumns[] = FeaturePeer::POSITION;
     347:         }
     348:
     349:
     350:         return $this;
     351:     } // setPosition()
     352:
     353:     /**
     354:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
     355:      *
     356:      * @param mixed $v string, integer (timestamp), or DateTime value.
     357:      *               Empty strings are treated as null.
     358:      * @return Feature The current object (for fluent API support)
     359:      */
     360:     public function setCreatedAt($v)
     361:     {
     362:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     363:         if ($this->created_at !== null || $dt !== null) {
     364:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     365:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     366:             if ($currentDateAsString !== $newDateAsString) {
     367:                 $this->created_at = $newDateAsString;
     368:                 $this->modifiedColumns[] = FeaturePeer::CREATED_AT;
     369:             }
     370:         } // if either are not null
     371:
     372:
     373:         return $this;
     374:     } // setCreatedAt()
     375:
     376:     /**
     377:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
     378:      *
     379:      * @param mixed $v string, integer (timestamp), or DateTime value.
     380:      *               Empty strings are treated as null.
     381:      * @return Feature The current object (for fluent API support)
     382:      */
     383:     public function setUpdatedAt($v)
     384:     {
     385:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     386:         if ($this->updated_at !== null || $dt !== null) {
     387:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     388:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     389:             if ($currentDateAsString !== $newDateAsString) {
     390:                 $this->updated_at = $newDateAsString;
     391:                 $this->modifiedColumns[] = FeaturePeer::UPDATED_AT;
     392:             }
     393:         } // if either are not null
     394:
     395:
     396:         return $this;
     397:     } // setUpdatedAt()
     398:
     399:     /**
     400:      * Indicates whether the columns in this object are only set to default values.
     401:      *
     402:      * This method can be used in conjunction with isModified() to indicate whether an object is both
     403:      * modified _and_ has some values set which are non-default.
     404:      *
     405:      * @return boolean Whether the columns in this object are only been set with default values.
     406:      */
     407:     public function hasOnlyDefaultValues()
     408:     {
     409:             if ($this->visible !== 0) {
     410:                 return false;
     411:             }
     412:
     413:         // otherwise, everything was equal, so return true
     414:         return true;
     415:     } // hasOnlyDefaultValues()
     416:
     417:     /**
     418:      * Hydrates (populates) the object variables with values from the database resultset.
     419:      *
     420:      * An offset (0-based "start column") is specified so that objects can be hydrated
     421:      * with a subset of the columns in the resultset rows.  This is needed, for example,
     422:      * for results of JOIN queries where the resultset row includes columns from two or
     423:      * more tables.
     424:      *
     425:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     426:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     427:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     428:      * @return int             next starting column
     429:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     430:      */
     431:     public function hydrate($row, $startcol = 0, $rehydrate = false)
     432:     {
     433:         try {
     434:
     435:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
     436:             $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
     437:             $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
     438:             $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
     439:             $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
     440:             $this->resetModified();
     441:
     442:             $this->setNew(false);
     443:
     444:             if ($rehydrate) {
     445:                 $this->ensureConsistency();
     446:             }
     447:
     448:             return $startcol + 5; // 5 = FeaturePeer::NUM_HYDRATE_COLUMNS.
     449:
     450:         } catch (Exception $e) {
     451:             throw new PropelException("Error populating Feature object", $e);
     452:         }
     453:     }
     454:
     455:     /**
     456:      * Checks and repairs the internal consistency of the object.
     457:      *
     458:      * This method is executed after an already-instantiated object is re-hydrated
     459:      * from the database.  It exists to check any foreign keys to make sure that
     460:      * the objects related to the current object are correct based on foreign key.
     461:      *
     462:      * You can override this method in the stub class, but you should always invoke
     463:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
     464:      * in case your model changes.
     465:      *
     466:      * @throws PropelException
     467:      */
     468:     public function ensureConsistency()
     469:     {
     470:
     471:     } // ensureConsistency
     472:
     473:     /**
     474:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     475:      *
     476:      * This will only work if the object has been saved and has a valid primary key set.
     477:      *
     478:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
     479:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
     480:      * @return void
     481:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     482:      */
     483:     public function reload($deep = false, PropelPDO $con = null)
     484:     {
     485:         if ($this->isDeleted()) {
     486:             throw new PropelException("Cannot reload a deleted object.");
     487:         }
     488:
     489:         if ($this->isNew()) {
     490:             throw new PropelException("Cannot reload an unsaved object.");
     491:         }
     492:
     493:         if ($con === null) {
     494:             $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     495:         }
     496:
     497:         // We don't need to alter the object instance pool; we're just modifying this instance
     498:         // already in the pool.
     499:
     500:         $stmt = FeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
     501:         $row = $stmt->fetch(PDO::FETCH_NUM);
     502:         $stmt->closeCursor();
     503:         if (!$row) {
     504:             throw new PropelException('Cannot find matching row in the database to reload object values.');
     505:         }
     506:         $this->hydrate($row, 0, true); // rehydrate
     507:
     508:         if ($deep) {  // also de-associate any related objects?
     509:
     510:             $this->collFeatureAvs = null;
     511:
     512:             $this->collFeatureProds = null;
     513:
     514:             $this->collFeatureCategorys = null;
     515:
     516:             $this->collFeatureI18ns = null;
     517:
     518:         } // if (deep)
     519:     }
     520:
     521:     /**
     522:      * Removes this object from datastore and sets delete attribute.
     523:      *
     524:      * @param PropelPDO $con
     525:      * @return void
     526:      * @throws PropelException
     527:      * @throws Exception
     528:      * @see        BaseObject::setDeleted()
     529:      * @see        BaseObject::isDeleted()
     530:      */
     531:     public function delete(PropelPDO $con = null)
     532:     {
     533:         if ($this->isDeleted()) {
     534:             throw new PropelException("This object has already been deleted.");
     535:         }
     536:
     537:         if ($con === null) {
     538:             $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     539:         }
     540:
     541:         $con->beginTransaction();
     542:         try {
     543:             $deleteQuery = FeatureQuery::create()
     544:                 ->filterByPrimaryKey($this->getPrimaryKey());
     545:             $ret = $this->preDelete($con);
     546:             if ($ret) {
     547:                 $deleteQuery->delete($con);
     548:                 $this->postDelete($con);
     549:                 $con->commit();
     550:                 $this->setDeleted(true);
     551:             } else {
     552:                 $con->commit();
     553:             }
     554:         } catch (Exception $e) {
     555:             $con->rollBack();
     556:             throw $e;
     557:         }
     558:     }
     559:
     560:     /**
     561:      * Persists this object to the database.
     562:      *
     563:      * If the object is new, it inserts it; otherwise an update is performed.
     564:      * All modified related objects will also be persisted in the doSave()
     565:      * method.  This method wraps all precipitate database operations in a
     566:      * single transaction.
     567:      *
     568:      * @param PropelPDO $con
     569:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     570:      * @throws PropelException
     571:      * @throws Exception
     572:      * @see        doSave()
     573:      */
     574:     public function save(PropelPDO $con = null)
     575:     {
     576:         if ($this->isDeleted()) {
     577:             throw new PropelException("You cannot save an object that has been deleted.");
     578:         }
     579:
     580:         if ($con === null) {
     581:             $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     582:         }
     583:
     584:         $con->beginTransaction();
     585:         $isInsert = $this->isNew();
     586:         try {
     587:             $ret = $this->preSave($con);
     588:             if ($isInsert) {
     589:                 $ret = $ret && $this->preInsert($con);
     590:                 // timestampable behavior
     591:                 if (!$this->isColumnModified(FeaturePeer::CREATED_AT)) {
     592:                     $this->setCreatedAt(time());
     593:                 }
     594:                 if (!$this->isColumnModified(FeaturePeer::UPDATED_AT)) {
     595:                     $this->setUpdatedAt(time());
     596:                 }
     597:             } else {
     598:                 $ret = $ret && $this->preUpdate($con);
     599:                 // timestampable behavior
     600:                 if ($this->isModified() && !$this->isColumnModified(FeaturePeer::UPDATED_AT)) {
     601:                     $this->setUpdatedAt(time());
     602:                 }
     603:             }
     604:             if ($ret) {
     605:                 $affectedRows = $this->doSave($con);
     606:                 if ($isInsert) {
     607:                     $this->postInsert($con);
     608:                 } else {
     609:                     $this->postUpdate($con);
     610:                 }
     611:                 $this->postSave($con);
     612:                 FeaturePeer::addInstanceToPool($this);
     613:             } else {
     614:                 $affectedRows = 0;
     615:             }
     616:             $con->commit();
     617:
     618:             return $affectedRows;
     619:         } catch (Exception $e) {
     620:             $con->rollBack();
     621:             throw $e;
     622:         }
     623:     }
     624:
     625:     /**
     626:      * Performs the work of inserting or updating the row in the database.
     627:      *
     628:      * If the object is new, it inserts it; otherwise an update is performed.
     629:      * All related objects are also updated in this method.
     630:      *
     631:      * @param PropelPDO $con
     632:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     633:      * @throws PropelException
     634:      * @see        save()
     635:      */
     636:     protected function doSave(PropelPDO $con)
     637:     {
     638:         $affectedRows = 0; // initialize var to track total num of affected rows
     639:         if (!$this->alreadyInSave) {
     640:             $this->alreadyInSave = true;
     641:
     642:             if ($this->isNew() || $this->isModified()) {
     643:                 // persist changes
     644:                 if ($this->isNew()) {
     645:                     $this->doInsert($con);
     646:                 } else {
     647:                     $this->doUpdate($con);
     648:                 }
     649:                 $affectedRows += 1;
     650:                 $this->resetModified();
     651:             }
     652:
     653:             if ($this->featureAvsScheduledForDeletion !== null) {
     654:                 if (!$this->featureAvsScheduledForDeletion->isEmpty()) {
     655:                     FeatureAvQuery::create()
     656:                         ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false))
     657:                         ->delete($con);
     658:                     $this->featureAvsScheduledForDeletion = null;
     659:                 }
     660:             }
     661:
     662:             if ($this->collFeatureAvs !== null) {
     663:                 foreach ($this->collFeatureAvs as $referrerFK) {
     664:                     if (!$referrerFK->isDeleted()) {
     665:                         $affectedRows += $referrerFK->save($con);
     666:                     }
     667:                 }
     668:             }
     669:
     670:             if ($this->featureProdsScheduledForDeletion !== null) {
     671:                 if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
     672:                     FeatureProdQuery::create()
     673:                         ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
     674:                         ->delete($con);
     675:                     $this->featureProdsScheduledForDeletion = null;
     676:                 }
     677:             }
     678:
     679:             if ($this->collFeatureProds !== null) {
     680:                 foreach ($this->collFeatureProds as $referrerFK) {
     681:                     if (!$referrerFK->isDeleted()) {
     682:                         $affectedRows += $referrerFK->save($con);
     683:                     }
     684:                 }
     685:             }
     686:
     687:             if ($this->featureCategorysScheduledForDeletion !== null) {
     688:                 if (!$this->featureCategorysScheduledForDeletion->isEmpty()) {
     689:                     FeatureCategoryQuery::create()
     690:                         ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false))
     691:                         ->delete($con);
     692:                     $this->featureCategorysScheduledForDeletion = null;
     693:                 }
     694:             }
     695:
     696:             if ($this->collFeatureCategorys !== null) {
     697:                 foreach ($this->collFeatureCategorys as $referrerFK) {
     698:                     if (!$referrerFK->isDeleted()) {
     699:                         $affectedRows += $referrerFK->save($con);
     700:                     }
     701:                 }
     702:             }
     703:
     704:             if ($this->featureI18nsScheduledForDeletion !== null) {
     705:                 if (!$this->featureI18nsScheduledForDeletion->isEmpty()) {
     706:                     FeatureI18nQuery::create()
     707:                         ->filterByPrimaryKeys($this->featureI18nsScheduledForDeletion->getPrimaryKeys(false))
     708:                         ->delete($con);
     709:                     $this->featureI18nsScheduledForDeletion = null;
     710:                 }
     711:             }
     712:
     713:             if ($this->collFeatureI18ns !== null) {
     714:                 foreach ($this->collFeatureI18ns as $referrerFK) {
     715:                     if (!$referrerFK->isDeleted()) {
     716:                         $affectedRows += $referrerFK->save($con);
     717:                     }
     718:                 }
     719:             }
     720:
     721:             $this->alreadyInSave = false;
     722:
     723:         }
     724:
     725:         return $affectedRows;
     726:     } // doSave()
     727:
     728:     /**
     729:      * Insert the row in the database.
     730:      *
     731:      * @param PropelPDO $con
     732:      *
     733:      * @throws PropelException
     734:      * @see        doSave()
     735:      */
     736:     protected function doInsert(PropelPDO $con)
     737:     {
     738:         $modifiedColumns = array();
     739:         $index = 0;
     740:
     741:         $this->modifiedColumns[] = FeaturePeer::ID;
     742:         if (null !== $this->id) {
     743:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeaturePeer::ID . ')');
     744:         }
     745:
     746:          // check the columns in natural order for more readable SQL queries
     747:         if ($this->isColumnModified(FeaturePeer::ID)) {
     748:             $modifiedColumns[':p' . $index++]  = '`ID`';
     749:         }
     750:         if ($this->isColumnModified(FeaturePeer::VISIBLE)) {
     751:             $modifiedColumns[':p' . $index++]  = '`VISIBLE`';
     752:         }
     753:         if ($this->isColumnModified(FeaturePeer::POSITION)) {
     754:             $modifiedColumns[':p' . $index++]  = '`POSITION`';
     755:         }
     756:         if ($this->isColumnModified(FeaturePeer::CREATED_AT)) {
     757:             $modifiedColumns[':p' . $index++]  = '`CREATED_AT`';
     758:         }
     759:         if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) {
     760:             $modifiedColumns[':p' . $index++]  = '`UPDATED_AT`';
     761:         }
     762:
     763:         $sql = sprintf(
     764:             'INSERT INTO `feature` (%s) VALUES (%s)',
     765:             implode(', ', $modifiedColumns),
     766:             implode(', ', array_keys($modifiedColumns))
     767:         );
     768:
     769:         try {
     770:             $stmt = $con->prepare($sql);
     771:             foreach ($modifiedColumns as $identifier => $columnName) {
     772:                 switch ($columnName) {
     773:                     case '`ID`':
     774:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
     775:                         break;
     776:                     case '`VISIBLE`':
     777:                         $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
     778:                         break;
     779:                     case '`POSITION`':
     780:                         $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
     781:                         break;
     782:                     case '`CREATED_AT`':
     783:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
     784:                         break;
     785:                     case '`UPDATED_AT`':
     786:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
     787:                         break;
     788:                 }
     789:             }
     790:             $stmt->execute();
     791:         } catch (Exception $e) {
     792:             Propel::log($e->getMessage(), Propel::LOG_ERR);
     793:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     794:         }
     795:
     796:         try {
     797:             $pk = $con->lastInsertId();
     798:         } catch (Exception $e) {
     799:             throw new PropelException('Unable to get autoincrement id.', $e);
     800:         }
     801:         $this->setId($pk);
     802:
     803:         $this->setNew(false);
     804:     }
     805:
     806:     /**
     807:      * Update the row in the database.
     808:      *
     809:      * @param PropelPDO $con
     810:      *
     811:      * @see        doSave()
     812:      */
     813:     protected function doUpdate(PropelPDO $con)
     814:     {
     815:         $selectCriteria = $this->buildPkeyCriteria();
     816:         $valuesCriteria = $this->buildCriteria();
     817:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
     818:     }
     819:
     820:     /**
     821:      * Array of ValidationFailed objects.
     822:      * @var        array ValidationFailed[]
     823:      */
     824:     protected $validationFailures = array();
     825:
     826:     /**
     827:      * Gets any ValidationFailed objects that resulted from last call to validate().
     828:      *
     829:      *
     830:      * @return array ValidationFailed[]
     831:      * @see        validate()
     832:      */
     833:     public function getValidationFailures()
     834:     {
     835:         return $this->validationFailures;
     836:     }
     837:
     838:     /**
     839:      * Validates the objects modified field values and all objects related to this table.
     840:      *
     841:      * If $columns is either a column name or an array of column names
     842:      * only those columns are validated.
     843:      *
     844:      * @param mixed $columns Column name or an array of column names.
     845:      * @return boolean Whether all columns pass validation.
     846:      * @see        doValidate()
     847:      * @see        getValidationFailures()
     848:      */
     849:     public function validate($columns = null)
     850:     {
     851:         $res = $this->doValidate($columns);
     852:         if ($res === true) {
     853:             $this->validationFailures = array();
     854:
     855:             return true;
     856:         } else {
     857:             $this->validationFailures = $res;
     858:
     859:             return false;
     860:         }
     861:     }
     862:
     863:     /**
     864:      * This function performs the validation work for complex object models.
     865:      *
     866:      * In addition to checking the current object, all related objects will
     867:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
     868:      * an aggreagated array of ValidationFailed objects will be returned.
     869:      *
     870:      * @param array $columns Array of column names to validate.
     871:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     872:      */
     873:     protected function doValidate($columns = null)
     874:     {
     875:         if (!$this->alreadyInValidation) {
     876:             $this->alreadyInValidation = true;
     877:             $retval = null;
     878:
     879:             $failureMap = array();
     880:
     881:
     882:             if (($retval = FeaturePeer::doValidate($this, $columns)) !== true) {
     883:                 $failureMap = array_merge($failureMap, $retval);
     884:             }
     885:
     886:
     887:                 if ($this->collFeatureAvs !== null) {
     888:                     foreach ($this->collFeatureAvs as $referrerFK) {
     889:                         if (!$referrerFK->validate($columns)) {
     890:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     891:                         }
     892:                     }
     893:                 }
     894:
     895:                 if ($this->collFeatureProds !== null) {
     896:                     foreach ($this->collFeatureProds as $referrerFK) {
     897:                         if (!$referrerFK->validate($columns)) {
     898:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     899:                         }
     900:                     }
     901:                 }
     902:
     903:                 if ($this->collFeatureCategorys !== null) {
     904:                     foreach ($this->collFeatureCategorys as $referrerFK) {
     905:                         if (!$referrerFK->validate($columns)) {
     906:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     907:                         }
     908:                     }
     909:                 }
     910:
     911:                 if ($this->collFeatureI18ns !== null) {
     912:                     foreach ($this->collFeatureI18ns as $referrerFK) {
     913:                         if (!$referrerFK->validate($columns)) {
     914:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     915:                         }
     916:                     }
     917:                 }
     918:
     919:
     920:             $this->alreadyInValidation = false;
     921:         }
     922:
     923:         return (!empty($failureMap) ? $failureMap : true);
     924:     }
     925:
     926:     /**
     927:      * Retrieves a field from the object by name passed in as a string.
     928:      *
     929:      * @param string $name name
     930:      * @param string $type The type of fieldname the $name is of:
     931:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     932:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     933:      *               Defaults to BasePeer::TYPE_PHPNAME
     934:      * @return mixed Value of field.
     935:      */
     936:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
     937:     {
     938:         $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     939:         $field = $this->getByPosition($pos);
     940:
     941:         return $field;
     942:     }
     943:
     944:     /**
     945:      * Retrieves a field from the object by Position as specified in the xml schema.
     946:      * Zero-based.
     947:      *
     948:      * @param int $pos position in xml schema
     949:      * @return mixed Value of field at $pos
     950:      */
     951:     public function getByPosition($pos)
     952:     {
     953:         switch ($pos) {
     954:             case 0:
     955:                 return $this->getId();
     956:                 break;
     957:             case 1:
     958:                 return $this->getVisible();
     959:                 break;
     960:             case 2:
     961:                 return $this->getPosition();
     962:                 break;
     963:             case 3:
     964:                 return $this->getCreatedAt();
     965:                 break;
     966:             case 4:
     967:                 return $this->getUpdatedAt();
     968:                 break;
     969:             default:
     970:                 return null;
     971:                 break;
     972:         } // switch()
     973:     }
     974:
     975:     /**
     976:      * Exports the object as an array.
     977:      *
     978:      * You can specify the key type of the array by passing one of the class
     979:      * type constants.
     980:      *
     981:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     982:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     983:      *                    Defaults to BasePeer::TYPE_PHPNAME.
     984:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     985:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     986:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     987:      *
     988:      * @return array an associative array containing the field names (as keys) and field values
     989:      */
     990:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
     991:     {
     992:         if (isset($alreadyDumpedObjects['Feature'][$this->getPrimaryKey()])) {
     993:             return '*RECURSION*';
     994:         }
     995:         $alreadyDumpedObjects['Feature'][$this->getPrimaryKey()] = true;
     996:         $keys = FeaturePeer::getFieldNames($keyType);
     997:         $result = array(
     998:             $keys[0] => $this->getId(),
     999:             $keys[1] => $this->getVisible(),
    1000:             $keys[2] => $this->getPosition(),
    1001:             $keys[3] => $this->getCreatedAt(),
    1002:             $keys[4] => $this->getUpdatedAt(),
    1003:         );
    1004:         if ($includeForeignObjects) {
    1005:             if (null !== $this->collFeatureAvs) {
    1006:                 $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
    1007:             }
    1008:             if (null !== $this->collFeatureProds) {
    1009:                 $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
    1010:             }
    1011:             if (null !== $this->collFeatureCategorys) {
    1012:                 $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
    1013:             }
    1014:             if (null !== $this->collFeatureI18ns) {
    1015:                 $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
    1016:             }
    1017:         }
    1018:
    1019:         return $result;
    1020:     }
    1021:
    1022:     /**
    1023:      * Sets a field from the object by name passed in as a string.
    1024:      *
    1025:      * @param string $name peer name
    1026:      * @param mixed $value field value
    1027:      * @param string $type The type of fieldname the $name is of:
    1028:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
    1029:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
    1030:      *                     Defaults to BasePeer::TYPE_PHPNAME
    1031:      * @return void
    1032:      */
    1033:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
    1034:     {
    1035:         $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
    1036:
    1037:         $this->setByPosition($pos, $value);
    1038:     }
    1039:
    1040:     /**
    1041:      * Sets a field from the object by Position as specified in the xml schema.
    1042:      * Zero-based.
    1043:      *
    1044:      * @param int $pos position in xml schema
    1045:      * @param mixed $value field value
    1046:      * @return void
    1047:      */
    1048:     public function setByPosition($pos, $value)
    1049:     {
    1050:         switch ($pos) {
    1051:             case 0:
    1052:                 $this->setId($value);
    1053:                 break;
    1054:             case 1:
    1055:                 $this->setVisible($value);
    1056:                 break;
    1057:             case 2:
    1058:                 $this->setPosition($value);
    1059:                 break;
    1060:             case 3:
    1061:                 $this->setCreatedAt($value);
    1062:                 break;
    1063:             case 4:
    1064:                 $this->setUpdatedAt($value);
    1065:                 break;
    1066:         } // switch()
    1067:     }
    1068:
    1069:     /**
    1070:      * Populates the object using an array.
    1071:      *
    1072:      * This is particularly useful when populating an object from one of the
    1073:      * request arrays (e.g. $_POST).  This method goes through the column
    1074:      * names, checking to see whether a matching key exists in populated
    1075:      * array. If so the setByName() method is called for that column.
    1076:      *
    1077:      * You can specify the key type of the array by additionally passing one
    1078:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
    1079:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
    1080:      * The default key type is the column's BasePeer::TYPE_PHPNAME
    1081:      *
    1082:      * @param array  $arr     An array to populate the object from.
    1083:      * @param string $keyType The type of keys the array uses.
    1084:      * @return void
    1085:      */
    1086:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    1087:     {
    1088:         $keys = FeaturePeer::getFieldNames($keyType);
    1089:
    1090:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
    1091:         if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
    1092:         if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
    1093:         if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
    1094:         if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
    1095:     }
    1096:
    1097:     /**
    1098:      * Build a Criteria object containing the values of all modified columns in this object.
    1099:      *
    1100:      * @return Criteria The Criteria object containing all modified values.
    1101:      */
    1102:     public function buildCriteria()
    1103:     {
    1104:         $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
    1105:
    1106:         if ($this->isColumnModified(FeaturePeer::ID)) $criteria->add(FeaturePeer::ID, $this->id);
    1107:         if ($this->isColumnModified(FeaturePeer::VISIBLE)) $criteria->add(FeaturePeer::VISIBLE, $this->visible);
    1108:         if ($this->isColumnModified(FeaturePeer::POSITION)) $criteria->add(FeaturePeer::POSITION, $this->position);
    1109:         if ($this->isColumnModified(FeaturePeer::CREATED_AT)) $criteria->add(FeaturePeer::CREATED_AT, $this->created_at);
    1110:         if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) $criteria->add(FeaturePeer::UPDATED_AT, $this->updated_at);
    1111:
    1112:         return $criteria;
    1113:     }
    1114:
    1115:     /**
    1116:      * Builds a Criteria object containing the primary key for this object.
    1117:      *
    1118:      * Unlike buildCriteria() this method includes the primary key values regardless
    1119:      * of whether or not they have been modified.
    1120:      *
    1121:      * @return Criteria The Criteria object containing value(s) for primary key(s).
    1122:      */
    1123:     public function buildPkeyCriteria()
    1124:     {
    1125:         $criteria = new Criteria(FeaturePeer::DATABASE_NAME);
    1126:         $criteria->add(FeaturePeer::ID, $this->id);
    1127:
    1128:         return $criteria;
    1129:     }
    1130:
    1131:     /**
    1132:      * Returns the primary key for this object (row).
    1133:      * @return int
    1134:      */
    1135:     public function getPrimaryKey()
    1136:     {
    1137:         return $this->getId();
    1138:     }
    1139:
    1140:     /**
    1141:      * Generic method to set the primary key (id column).
    1142:      *
    1143:      * @param  int $key Primary key.
    1144:      * @return void
    1145:      */
    1146:     public function setPrimaryKey($key)
    1147:     {
    1148:         $this->setId($key);
    1149:     }
    1150:
    1151:     /**
    1152:      * Returns true if the primary key for this object is null.
    1153:      * @return boolean
    1154:      */
    1155:     public function isPrimaryKeyNull()
    1156:     {
    1157:
    1158:         return null === $this->getId();
    1159:     }
    1160:
    1161:     /**
    1162:      * Sets contents of passed object to values from current object.
    1163:      *
    1164:      * If desired, this method can also make copies of all associated (fkey referrers)
    1165:      * objects.
    1166:      *
    1167:      * @param object $copyObj An object of Feature (or compatible) type.
    1168:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1169:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
    1170:      * @throws PropelException
    1171:      */
    1172:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    1173:     {
    1174:         $copyObj->setVisible($this->getVisible());
    1175:         $copyObj->setPosition($this->getPosition());
    1176:         $copyObj->setCreatedAt($this->getCreatedAt());
    1177:         $copyObj->setUpdatedAt($this->getUpdatedAt());
    1178:
    1179:         if ($deepCopy && !$this->startCopy) {
    1180:             // important: temporarily setNew(false) because this affects the behavior of
    1181:             // the getter/setter methods for fkey referrer objects.
    1182:             $copyObj->setNew(false);
    1183:             // store object hash to prevent cycle
    1184:             $this->startCopy = true;
    1185:
    1186:             foreach ($this->getFeatureAvs() as $relObj) {
    1187:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1188:                     $copyObj->addFeatureAv($relObj->copy($deepCopy));
    1189:                 }
    1190:             }
    1191:
    1192:             foreach ($this->getFeatureProds() as $relObj) {
    1193:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1194:                     $copyObj->addFeatureProd($relObj->copy($deepCopy));
    1195:                 }
    1196:             }
    1197:
    1198:             foreach ($this->getFeatureCategorys() as $relObj) {
    1199:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1200:                     $copyObj->addFeatureCategory($relObj->copy($deepCopy));
    1201:                 }
    1202:             }
    1203:
    1204:             foreach ($this->getFeatureI18ns() as $relObj) {
    1205:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1206:                     $copyObj->addFeatureI18n($relObj->copy($deepCopy));
    1207:                 }
    1208:             }
    1209:
    1210:             //unflag object copy
    1211:             $this->startCopy = false;
    1212:         } // if ($deepCopy)
    1213:
    1214:         if ($makeNew) {
    1215:             $copyObj->setNew(true);
    1216:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
    1217:         }
    1218:     }
    1219:
    1220:     /**
    1221:      * Makes a copy of this object that will be inserted as a new row in table when saved.
    1222:      * It creates a new object filling in the simple attributes, but skipping any primary
    1223:      * keys that are defined for the table.
    1224:      *
    1225:      * If desired, this method can also make copies of all associated (fkey referrers)
    1226:      * objects.
    1227:      *
    1228:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1229:      * @return Feature Clone of current object.
    1230:      * @throws PropelException
    1231:      */
    1232:     public function copy($deepCopy = false)
    1233:     {
    1234:         // we use get_class(), because this might be a subclass
    1235:         $clazz = get_class($this);
    1236:         $copyObj = new $clazz();
    1237:         $this->copyInto($copyObj, $deepCopy);
    1238:
    1239:         return $copyObj;
    1240:     }
    1241:
    1242:     /**
    1243:      * Returns a peer instance associated with this om.
    1244:      *
    1245:      * Since Peer classes are not to have any instance attributes, this method returns the
    1246:      * same instance for all member of this class. The method could therefore
    1247:      * be static, but this would prevent one from overriding the behavior.
    1248:      *
    1249:      * @return FeaturePeer
    1250:      */
    1251:     public function getPeer()
    1252:     {
    1253:         if (self::$peer === null) {
    1254:             self::$peer = new FeaturePeer();
    1255:         }
    1256:
    1257:         return self::$peer;
    1258:     }
    1259:
    1260:
    1261:     /**
    1262:      * Initializes a collection based on the name of a relation.
    1263:      * Avoids crafting an 'init[$relationName]s' method name
    1264:      * that wouldn't work when StandardEnglishPluralizer is used.
    1265:      *
    1266:      * @param string $relationName The name of the relation to initialize
    1267:      * @return void
    1268:      */
    1269:     public function initRelation($relationName)
    1270:     {
    1271:         if ('FeatureAv' == $relationName) {
    1272:             $this->initFeatureAvs();
    1273:         }
    1274:         if ('FeatureProd' == $relationName) {
    1275:             $this->initFeatureProds();
    1276:         }
    1277:         if ('FeatureCategory' == $relationName) {
    1278:             $this->initFeatureCategorys();
    1279:         }
    1280:         if ('FeatureI18n' == $relationName) {
    1281:             $this->initFeatureI18ns();
    1282:         }
    1283:     }
    1284:
    1285:     /**
    1286:      * Clears out the collFeatureAvs collection
    1287:      *
    1288:      * This does not modify the database; however, it will remove any associated objects, causing
    1289:      * them to be refetched by subsequent calls to accessor method.
    1290:      *
    1291:      * @return void
    1292:      * @see        addFeatureAvs()
    1293:      */
    1294:     public function clearFeatureAvs()
    1295:     {
    1296:         $this->collFeatureAvs = null; // important to set this to null since that means it is uninitialized
    1297:         $this->collFeatureAvsPartial = null;
    1298:     }
    1299:
    1300:     /**
    1301:      * reset is the collFeatureAvs collection loaded partially
    1302:      *
    1303:      * @return void
    1304:      */
    1305:     public function resetPartialFeatureAvs($v = true)
    1306:     {
    1307:         $this->collFeatureAvsPartial = $v;
    1308:     }
    1309:
    1310:     /**
    1311:      * Initializes the collFeatureAvs collection.
    1312:      *
    1313:      * By default this just sets the collFeatureAvs collection to an empty array (like clearcollFeatureAvs());
    1314:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1315:      * to your application -- for example, setting the initial array to the values stored in database.
    1316:      *
    1317:      * @param boolean $overrideExisting If set to true, the method call initializes
    1318:      *                                        the collection even if it is not empty
    1319:      *
    1320:      * @return void
    1321:      */
    1322:     public function initFeatureAvs($overrideExisting = true)
    1323:     {
    1324:         if (null !== $this->collFeatureAvs && !$overrideExisting) {
    1325:             return;
    1326:         }
    1327:         $this->collFeatureAvs = new PropelObjectCollection();
    1328:         $this->collFeatureAvs->setModel('FeatureAv');
    1329:     }
    1330:
    1331:     /**
    1332:      * Gets an array of FeatureAv objects which contain a foreign key that references this object.
    1333:      *
    1334:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1335:      * Otherwise the results are fetched from the database the first time, then cached.
    1336:      * Next time the same method is called without $criteria, the cached collection is returned.
    1337:      * If this Feature is new, it will return
    1338:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1339:      *
    1340:      * @param Criteria $criteria optional Criteria object to narrow the query
    1341:      * @param PropelPDO $con optional connection object
    1342:      * @return PropelObjectCollection|FeatureAv[] List of FeatureAv objects
    1343:      * @throws PropelException
    1344:      */
    1345:     public function getFeatureAvs($criteria = null, PropelPDO $con = null)
    1346:     {
    1347:         $partial = $this->collFeatureAvsPartial && !$this->isNew();
    1348:         if (null === $this->collFeatureAvs || null !== $criteria  || $partial) {
    1349:             if ($this->isNew() && null === $this->collFeatureAvs) {
    1350:                 // return empty collection
    1351:                 $this->initFeatureAvs();
    1352:             } else {
    1353:                 $collFeatureAvs = FeatureAvQuery::create(null, $criteria)
    1354:                     ->filterByFeature($this)
    1355:                     ->find($con);
    1356:                 if (null !== $criteria) {
    1357:                     if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) {
    1358:                       $this->initFeatureAvs(false);
    1359:
    1360:                       foreach($collFeatureAvs as $obj) {
    1361:                         if (false == $this->collFeatureAvs->contains($obj)) {
    1362:                           $this->collFeatureAvs->append($obj);
    1363:                         }
    1364:                       }
    1365:
    1366:                       $this->collFeatureAvsPartial = true;
    1367:                     }
    1368:
    1369:                     return $collFeatureAvs;
    1370:                 }
    1371:
    1372:                 if($partial && $this->collFeatureAvs) {
    1373:                     foreach($this->collFeatureAvs as $obj) {
    1374:                         if($obj->isNew()) {
    1375:                             $collFeatureAvs[] = $obj;
    1376:                         }
    1377:                     }
    1378:                 }
    1379:
    1380:                 $this->collFeatureAvs = $collFeatureAvs;
    1381:                 $this->collFeatureAvsPartial = false;
    1382:             }
    1383:         }
    1384:
    1385:         return $this->collFeatureAvs;
    1386:     }
    1387:
    1388:     /**
    1389:      * Sets a collection of FeatureAv objects related by a one-to-many relationship
    1390:      * to the current object.
    1391:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1392:      * and new objects from the given Propel collection.
    1393:      *
    1394:      * @param PropelCollection $featureAvs A Propel collection.
    1395:      * @param PropelPDO $con Optional connection object
    1396:      */
    1397:     public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null)
    1398:     {
    1399:         $this->featureAvsScheduledForDeletion = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs);
    1400:
    1401:         foreach ($this->featureAvsScheduledForDeletion as $featureAvRemoved) {
    1402:             $featureAvRemoved->setFeature(null);
    1403:         }
    1404:
    1405:         $this->collFeatureAvs = null;
    1406:         foreach ($featureAvs as $featureAv) {
    1407:             $this->addFeatureAv($featureAv);
    1408:         }
    1409:
    1410:         $this->collFeatureAvs = $featureAvs;
    1411:         $this->collFeatureAvsPartial = false;
    1412:     }
    1413:
    1414:     /**
    1415:      * Returns the number of related FeatureAv objects.
    1416:      *
    1417:      * @param Criteria $criteria
    1418:      * @param boolean $distinct
    1419:      * @param PropelPDO $con
    1420:      * @return int             Count of related FeatureAv objects.
    1421:      * @throws PropelException
    1422:      */
    1423:     public function countFeatureAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1424:     {
    1425:         $partial = $this->collFeatureAvsPartial && !$this->isNew();
    1426:         if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
    1427:             if ($this->isNew() && null === $this->collFeatureAvs) {
    1428:                 return 0;
    1429:             } else {
    1430:                 if($partial && !$criteria) {
    1431:                     return count($this->getFeatureAvs());
    1432:                 }
    1433:                 $query = FeatureAvQuery::create(null, $criteria);
    1434:                 if ($distinct) {
    1435:                     $query->distinct();
    1436:                 }
    1437:
    1438:                 return $query
    1439:                     ->filterByFeature($this)
    1440:                     ->count($con);
    1441:             }
    1442:         } else {
    1443:             return count($this->collFeatureAvs);
    1444:         }
    1445:     }
    1446:
    1447:     /**
    1448:      * Method called to associate a FeatureAv object to this object
    1449:      * through the FeatureAv foreign key attribute.
    1450:      *
    1451:      * @param    FeatureAv $l FeatureAv
    1452:      * @return Feature The current object (for fluent API support)
    1453:      */
    1454:     public function addFeatureAv(FeatureAv $l)
    1455:     {
    1456:         if ($this->collFeatureAvs === null) {
    1457:             $this->initFeatureAvs();
    1458:             $this->collFeatureAvsPartial = true;
    1459:         }
    1460:         if (!$this->collFeatureAvs->contains($l)) { // only add it if the **same** object is not already associated
    1461:             $this->doAddFeatureAv($l);
    1462:         }
    1463:
    1464:         return $this;
    1465:     }
    1466:
    1467:     /**
    1468:      * @param   FeatureAv $featureAv The featureAv object to add.
    1469:      */
    1470:     protected function doAddFeatureAv($featureAv)
    1471:     {
    1472:         $this->collFeatureAvs[]= $featureAv;
    1473:         $featureAv->setFeature($this);
    1474:     }
    1475:
    1476:     /**
    1477:      * @param   FeatureAv $featureAv The featureAv object to remove.
    1478:      */
    1479:     public function removeFeatureAv($featureAv)
    1480:     {
    1481:         if ($this->getFeatureAvs()->contains($featureAv)) {
    1482:             $this->collFeatureAvs->remove($this->collFeatureAvs->search($featureAv));
    1483:             if (null === $this->featureAvsScheduledForDeletion) {
    1484:                 $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs;
    1485:                 $this->featureAvsScheduledForDeletion->clear();
    1486:             }
    1487:             $this->featureAvsScheduledForDeletion[]= $featureAv;
    1488:             $featureAv->setFeature(null);
    1489:         }
    1490:     }
    1491:
    1492:     /**
    1493:      * Clears out the collFeatureProds collection
    1494:      *
    1495:      * This does not modify the database; however, it will remove any associated objects, causing
    1496:      * them to be refetched by subsequent calls to accessor method.
    1497:      *
    1498:      * @return void
    1499:      * @see        addFeatureProds()
    1500:      */
    1501:     public function clearFeatureProds()
    1502:     {
    1503:         $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized
    1504:         $this->collFeatureProdsPartial = null;
    1505:     }
    1506:
    1507:     /**
    1508:      * reset is the collFeatureProds collection loaded partially
    1509:      *
    1510:      * @return void
    1511:      */
    1512:     public function resetPartialFeatureProds($v = true)
    1513:     {
    1514:         $this->collFeatureProdsPartial = $v;
    1515:     }
    1516:
    1517:     /**
    1518:      * Initializes the collFeatureProds collection.
    1519:      *
    1520:      * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
    1521:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1522:      * to your application -- for example, setting the initial array to the values stored in database.
    1523:      *
    1524:      * @param boolean $overrideExisting If set to true, the method call initializes
    1525:      *                                        the collection even if it is not empty
    1526:      *
    1527:      * @return void
    1528:      */
    1529:     public function initFeatureProds($overrideExisting = true)
    1530:     {
    1531:         if (null !== $this->collFeatureProds && !$overrideExisting) {
    1532:             return;
    1533:         }
    1534:         $this->collFeatureProds = new PropelObjectCollection();
    1535:         $this->collFeatureProds->setModel('FeatureProd');
    1536:     }
    1537:
    1538:     /**
    1539:      * Gets an array of FeatureProd objects which contain a foreign key that references this object.
    1540:      *
    1541:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1542:      * Otherwise the results are fetched from the database the first time, then cached.
    1543:      * Next time the same method is called without $criteria, the cached collection is returned.
    1544:      * If this Feature is new, it will return
    1545:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1546:      *
    1547:      * @param Criteria $criteria optional Criteria object to narrow the query
    1548:      * @param PropelPDO $con optional connection object
    1549:      * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
    1550:      * @throws PropelException
    1551:      */
    1552:     public function getFeatureProds($criteria = null, PropelPDO $con = null)
    1553:     {
    1554:         $partial = $this->collFeatureProdsPartial && !$this->isNew();
    1555:         if (null === $this->collFeatureProds || null !== $criteria  || $partial) {
    1556:             if ($this->isNew() && null === $this->collFeatureProds) {
    1557:                 // return empty collection
    1558:                 $this->initFeatureProds();
    1559:             } else {
    1560:                 $collFeatureProds = FeatureProdQuery::create(null, $criteria)
    1561:                     ->filterByFeature($this)
    1562:                     ->find($con);
    1563:                 if (null !== $criteria) {
    1564:                     if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
    1565:                       $this->initFeatureProds(false);
    1566:
    1567:                       foreach($collFeatureProds as $obj) {
    1568:                         if (false == $this->collFeatureProds->contains($obj)) {
    1569:                           $this->collFeatureProds->append($obj);
    1570:                         }
    1571:                       }
    1572:
    1573:                       $this->collFeatureProdsPartial = true;
    1574:                     }
    1575:
    1576:                     return $collFeatureProds;
    1577:                 }
    1578:
    1579:                 if($partial && $this->collFeatureProds) {
    1580:                     foreach($this->collFeatureProds as $obj) {
    1581:                         if($obj->isNew()) {
    1582:                             $collFeatureProds[] = $obj;
    1583:                         }
    1584:                     }
    1585:                 }
    1586:
    1587:                 $this->collFeatureProds = $collFeatureProds;
    1588:                 $this->collFeatureProdsPartial = false;
    1589:             }
    1590:         }
    1591:
    1592:         return $this->collFeatureProds;
    1593:     }
    1594:
    1595:     /**
    1596:      * Sets a collection of FeatureProd objects related by a one-to-many relationship
    1597:      * to the current object.
    1598:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1599:      * and new objects from the given Propel collection.
    1600:      *
    1601:      * @param PropelCollection $featureProds A Propel collection.
    1602:      * @param PropelPDO $con Optional connection object
    1603:      */
    1604:     public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null)
    1605:     {
    1606:         $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
    1607:
    1608:         foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) {
    1609:             $featureProdRemoved->setFeature(null);
    1610:         }
    1611:
    1612:         $this->collFeatureProds = null;
    1613:         foreach ($featureProds as $featureProd) {
    1614:             $this->addFeatureProd($featureProd);
    1615:         }
    1616:
    1617:         $this->collFeatureProds = $featureProds;
    1618:         $this->collFeatureProdsPartial = false;
    1619:     }
    1620:
    1621:     /**
    1622:      * Returns the number of related FeatureProd objects.
    1623:      *
    1624:      * @param Criteria $criteria
    1625:      * @param boolean $distinct
    1626:      * @param PropelPDO $con
    1627:      * @return int             Count of related FeatureProd objects.
    1628:      * @throws PropelException
    1629:      */
    1630:     public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1631:     {
    1632:         $partial = $this->collFeatureProdsPartial && !$this->isNew();
    1633:         if (null === $this->collFeatureProds || null !== $criteria || $partial) {
    1634:             if ($this->isNew() && null === $this->collFeatureProds) {
    1635:                 return 0;
    1636:             } else {
    1637:                 if($partial && !$criteria) {
    1638:                     return count($this->getFeatureProds());
    1639:                 }
    1640:                 $query = FeatureProdQuery::create(null, $criteria);
    1641:                 if ($distinct) {
    1642:                     $query->distinct();
    1643:                 }
    1644:
    1645:                 return $query
    1646:                     ->filterByFeature($this)
    1647:                     ->count($con);
    1648:             }
    1649:         } else {
    1650:             return count($this->collFeatureProds);
    1651:         }
    1652:     }
    1653:
    1654:     /**
    1655:      * Method called to associate a FeatureProd object to this object
    1656:      * through the FeatureProd foreign key attribute.
    1657:      *
    1658:      * @param    FeatureProd $l FeatureProd
    1659:      * @return Feature The current object (for fluent API support)
    1660:      */
    1661:     public function addFeatureProd(FeatureProd $l)
    1662:     {
    1663:         if ($this->collFeatureProds === null) {
    1664:             $this->initFeatureProds();
    1665:             $this->collFeatureProdsPartial = true;
    1666:         }
    1667:         if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated
    1668:             $this->doAddFeatureProd($l);
    1669:         }
    1670:
    1671:         return $this;
    1672:     }
    1673:
    1674:     /**
    1675:      * @param   FeatureProd $featureProd The featureProd object to add.
    1676:      */
    1677:     protected function doAddFeatureProd($featureProd)
    1678:     {
    1679:         $this->collFeatureProds[]= $featureProd;
    1680:         $featureProd->setFeature($this);
    1681:     }
    1682:
    1683:     /**
    1684:      * @param   FeatureProd $featureProd The featureProd object to remove.
    1685:      */
    1686:     public function removeFeatureProd($featureProd)
    1687:     {
    1688:         if ($this->getFeatureProds()->contains($featureProd)) {
    1689:             $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
    1690:             if (null === $this->featureProdsScheduledForDeletion) {
    1691:                 $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
    1692:                 $this->featureProdsScheduledForDeletion->clear();
    1693:             }
    1694:             $this->featureProdsScheduledForDeletion[]= $featureProd;
    1695:             $featureProd->setFeature(null);
    1696:         }
    1697:     }
    1698:
    1699:
    1700:     /**
    1701:      * If this collection has already been initialized with
    1702:      * an identical criteria, it returns the collection.
    1703:      * Otherwise if this Feature is new, it will return
    1704:      * an empty collection; or if this Feature has previously
    1705:      * been saved, it will retrieve related FeatureProds from storage.
    1706:      *
    1707:      * This method is protected by default in order to keep the public
    1708:      * api reasonable.  You can provide public methods for those you
    1709:      * actually need in Feature.
    1710:      *
    1711:      * @param Criteria $criteria optional Criteria object to narrow the query
    1712:      * @param PropelPDO $con optional connection object
    1713:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1714:      * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
    1715:      */
    1716:     public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1717:     {
    1718:         $query = FeatureProdQuery::create(null, $criteria);
    1719:         $query->joinWith('Product', $join_behavior);
    1720:
    1721:         return $this->getFeatureProds($query, $con);
    1722:     }
    1723:
    1724:
    1725:     /**
    1726:      * If this collection has already been initialized with
    1727:      * an identical criteria, it returns the collection.
    1728:      * Otherwise if this Feature is new, it will return
    1729:      * an empty collection; or if this Feature has previously
    1730:      * been saved, it will retrieve related FeatureProds from storage.
    1731:      *
    1732:      * This method is protected by default in order to keep the public
    1733:      * api reasonable.  You can provide public methods for those you
    1734:      * actually need in Feature.
    1735:      *
    1736:      * @param Criteria $criteria optional Criteria object to narrow the query
    1737:      * @param PropelPDO $con optional connection object
    1738:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1739:      * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects
    1740:      */
    1741:     public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1742:     {
    1743:         $query = FeatureProdQuery::create(null, $criteria);
    1744:         $query->joinWith('FeatureAv', $join_behavior);
    1745:
    1746:         return $this->getFeatureProds($query, $con);
    1747:     }
    1748:
    1749:     /**
    1750:      * Clears out the collFeatureCategorys collection
    1751:      *
    1752:      * This does not modify the database; however, it will remove any associated objects, causing
    1753:      * them to be refetched by subsequent calls to accessor method.
    1754:      *
    1755:      * @return void
    1756:      * @see        addFeatureCategorys()
    1757:      */
    1758:     public function clearFeatureCategorys()
    1759:     {
    1760:         $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized
    1761:         $this->collFeatureCategorysPartial = null;
    1762:     }
    1763:
    1764:     /**
    1765:      * reset is the collFeatureCategorys collection loaded partially
    1766:      *
    1767:      * @return void
    1768:      */
    1769:     public function resetPartialFeatureCategorys($v = true)
    1770:     {
    1771:         $this->collFeatureCategorysPartial = $v;
    1772:     }
    1773:
    1774:     /**
    1775:      * Initializes the collFeatureCategorys collection.
    1776:      *
    1777:      * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys());
    1778:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1779:      * to your application -- for example, setting the initial array to the values stored in database.
    1780:      *
    1781:      * @param boolean $overrideExisting If set to true, the method call initializes
    1782:      *                                        the collection even if it is not empty
    1783:      *
    1784:      * @return void
    1785:      */
    1786:     public function initFeatureCategorys($overrideExisting = true)
    1787:     {
    1788:         if (null !== $this->collFeatureCategorys && !$overrideExisting) {
    1789:             return;
    1790:         }
    1791:         $this->collFeatureCategorys = new PropelObjectCollection();
    1792:         $this->collFeatureCategorys->setModel('FeatureCategory');
    1793:     }
    1794:
    1795:     /**
    1796:      * Gets an array of FeatureCategory objects which contain a foreign key that references this object.
    1797:      *
    1798:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1799:      * Otherwise the results are fetched from the database the first time, then cached.
    1800:      * Next time the same method is called without $criteria, the cached collection is returned.
    1801:      * If this Feature is new, it will return
    1802:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1803:      *
    1804:      * @param Criteria $criteria optional Criteria object to narrow the query
    1805:      * @param PropelPDO $con optional connection object
    1806:      * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
    1807:      * @throws PropelException
    1808:      */
    1809:     public function getFeatureCategorys($criteria = null, PropelPDO $con = null)
    1810:     {
    1811:         $partial = $this->collFeatureCategorysPartial && !$this->isNew();
    1812:         if (null === $this->collFeatureCategorys || null !== $criteria  || $partial) {
    1813:             if ($this->isNew() && null === $this->collFeatureCategorys) {
    1814:                 // return empty collection
    1815:                 $this->initFeatureCategorys();
    1816:             } else {
    1817:                 $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria)
    1818:                     ->filterByFeature($this)
    1819:                     ->find($con);
    1820:                 if (null !== $criteria) {
    1821:                     if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) {
    1822:                       $this->initFeatureCategorys(false);
    1823:
    1824:                       foreach($collFeatureCategorys as $obj) {
    1825:                         if (false == $this->collFeatureCategorys->contains($obj)) {
    1826:                           $this->collFeatureCategorys->append($obj);
    1827:                         }
    1828:                       }
    1829:
    1830:                       $this->collFeatureCategorysPartial = true;
    1831:                     }
    1832:
    1833:                     return $collFeatureCategorys;
    1834:                 }
    1835:
    1836:                 if($partial && $this->collFeatureCategorys) {
    1837:                     foreach($this->collFeatureCategorys as $obj) {
    1838:                         if($obj->isNew()) {
    1839:                             $collFeatureCategorys[] = $obj;
    1840:                         }
    1841:                     }
    1842:                 }
    1843:
    1844:                 $this->collFeatureCategorys = $collFeatureCategorys;
    1845:                 $this->collFeatureCategorysPartial = false;
    1846:             }
    1847:         }
    1848:
    1849:         return $this->collFeatureCategorys;
    1850:     }
    1851:
    1852:     /**
    1853:      * Sets a collection of FeatureCategory objects related by a one-to-many relationship
    1854:      * to the current object.
    1855:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1856:      * and new objects from the given Propel collection.
    1857:      *
    1858:      * @param PropelCollection $featureCategorys A Propel collection.
    1859:      * @param PropelPDO $con Optional connection object
    1860:      */
    1861:     public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null)
    1862:     {
    1863:         $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys);
    1864:
    1865:         foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) {
    1866:             $featureCategoryRemoved->setFeature(null);
    1867:         }
    1868:
    1869:         $this->collFeatureCategorys = null;
    1870:         foreach ($featureCategorys as $featureCategory) {
    1871:             $this->addFeatureCategory($featureCategory);
    1872:         }
    1873:
    1874:         $this->collFeatureCategorys = $featureCategorys;
    1875:         $this->collFeatureCategorysPartial = false;
    1876:     }
    1877:
    1878:     /**
    1879:      * Returns the number of related FeatureCategory objects.
    1880:      *
    1881:      * @param Criteria $criteria
    1882:      * @param boolean $distinct
    1883:      * @param PropelPDO $con
    1884:      * @return int             Count of related FeatureCategory objects.
    1885:      * @throws PropelException
    1886:      */
    1887:     public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1888:     {
    1889:         $partial = $this->collFeatureCategorysPartial && !$this->isNew();
    1890:         if (null === $this->collFeatureCategorys || null !== $criteria || $partial) {
    1891:             if ($this->isNew() && null === $this->collFeatureCategorys) {
    1892:                 return 0;
    1893:             } else {
    1894:                 if($partial && !$criteria) {
    1895:                     return count($this->getFeatureCategorys());
    1896:                 }
    1897:                 $query = FeatureCategoryQuery::create(null, $criteria);
    1898:                 if ($distinct) {
    1899:                     $query->distinct();
    1900:                 }
    1901:
    1902:                 return $query
    1903:                     ->filterByFeature($this)
    1904:                     ->count($con);
    1905:             }
    1906:         } else {
    1907:             return count($this->collFeatureCategorys);
    1908:         }
    1909:     }
    1910:
    1911:     /**
    1912:      * Method called to associate a FeatureCategory object to this object
    1913:      * through the FeatureCategory foreign key attribute.
    1914:      *
    1915:      * @param    FeatureCategory $l FeatureCategory
    1916:      * @return Feature The current object (for fluent API support)
    1917:      */
    1918:     public function addFeatureCategory(FeatureCategory $l)
    1919:     {
    1920:         if ($this->collFeatureCategorys === null) {
    1921:             $this->initFeatureCategorys();
    1922:             $this->collFeatureCategorysPartial = true;
    1923:         }
    1924:         if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated
    1925:             $this->doAddFeatureCategory($l);
    1926:         }
    1927:
    1928:         return $this;
    1929:     }
    1930:
    1931:     /**
    1932:      * @param   FeatureCategory $featureCategory The featureCategory object to add.
    1933:      */
    1934:     protected function doAddFeatureCategory($featureCategory)
    1935:     {
    1936:         $this->collFeatureCategorys[]= $featureCategory;
    1937:         $featureCategory->setFeature($this);
    1938:     }
    1939:
    1940:     /**
    1941:      * @param   FeatureCategory $featureCategory The featureCategory object to remove.
    1942:      */
    1943:     public function removeFeatureCategory($featureCategory)
    1944:     {
    1945:         if ($this->getFeatureCategorys()->contains($featureCategory)) {
    1946:             $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory));
    1947:             if (null === $this->featureCategorysScheduledForDeletion) {
    1948:                 $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys;
    1949:                 $this->featureCategorysScheduledForDeletion->clear();
    1950:             }
    1951:             $this->featureCategorysScheduledForDeletion[]= $featureCategory;
    1952:             $featureCategory->setFeature(null);
    1953:         }
    1954:     }
    1955:
    1956:
    1957:     /**
    1958:      * If this collection has already been initialized with
    1959:      * an identical criteria, it returns the collection.
    1960:      * Otherwise if this Feature is new, it will return
    1961:      * an empty collection; or if this Feature has previously
    1962:      * been saved, it will retrieve related FeatureCategorys from storage.
    1963:      *
    1964:      * This method is protected by default in order to keep the public
    1965:      * api reasonable.  You can provide public methods for those you
    1966:      * actually need in Feature.
    1967:      *
    1968:      * @param Criteria $criteria optional Criteria object to narrow the query
    1969:      * @param PropelPDO $con optional connection object
    1970:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1971:      * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects
    1972:      */
    1973:     public function getFeatureCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1974:     {
    1975:         $query = FeatureCategoryQuery::create(null, $criteria);
    1976:         $query->joinWith('Category', $join_behavior);
    1977:
    1978:         return $this->getFeatureCategorys($query, $con);
    1979:     }
    1980:
    1981:     /**
    1982:      * Clears out the collFeatureI18ns collection
    1983:      *
    1984:      * This does not modify the database; however, it will remove any associated objects, causing
    1985:      * them to be refetched by subsequent calls to accessor method.
    1986:      *
    1987:      * @return void
    1988:      * @see        addFeatureI18ns()
    1989:      */
    1990:     public function clearFeatureI18ns()
    1991:     {
    1992:         $this->collFeatureI18ns = null; // important to set this to null since that means it is uninitialized
    1993:         $this->collFeatureI18nsPartial = null;
    1994:     }
    1995:
    1996:     /**
    1997:      * reset is the collFeatureI18ns collection loaded partially
    1998:      *
    1999:      * @return void
    2000:      */
    2001:     public function resetPartialFeatureI18ns($v = true)
    2002:     {
    2003:         $this->collFeatureI18nsPartial = $v;
    2004:     }
    2005:
    2006:     /**
    2007:      * Initializes the collFeatureI18ns collection.
    2008:      *
    2009:      * By default this just sets the collFeatureI18ns collection to an empty array (like clearcollFeatureI18ns());
    2010:      * however, you may wish to override this method in your stub class to provide setting appropriate
    2011:      * to your application -- for example, setting the initial array to the values stored in database.
    2012:      *
    2013:      * @param boolean $overrideExisting If set to true, the method call initializes
    2014:      *                                        the collection even if it is not empty
    2015:      *
    2016:      * @return void
    2017:      */
    2018:     public function initFeatureI18ns($overrideExisting = true)
    2019:     {
    2020:         if (null !== $this->collFeatureI18ns && !$overrideExisting) {
    2021:             return;
    2022:         }
    2023:         $this->collFeatureI18ns = new PropelObjectCollection();
    2024:         $this->collFeatureI18ns->setModel('FeatureI18n');
    2025:     }
    2026:
    2027:     /**
    2028:      * Gets an array of FeatureI18n objects which contain a foreign key that references this object.
    2029:      *
    2030:      * If the $criteria is not null, it is used to always fetch the results from the database.
    2031:      * Otherwise the results are fetched from the database the first time, then cached.
    2032:      * Next time the same method is called without $criteria, the cached collection is returned.
    2033:      * If this Feature is new, it will return
    2034:      * an empty collection or the current collection; the criteria is ignored on a new object.
    2035:      *
    2036:      * @param Criteria $criteria optional Criteria object to narrow the query
    2037:      * @param PropelPDO $con optional connection object
    2038:      * @return PropelObjectCollection|FeatureI18n[] List of FeatureI18n objects
    2039:      * @throws PropelException
    2040:      */
    2041:     public function getFeatureI18ns($criteria = null, PropelPDO $con = null)
    2042:     {
    2043:         $partial = $this->collFeatureI18nsPartial && !$this->isNew();
    2044:         if (null === $this->collFeatureI18ns || null !== $criteria  || $partial) {
    2045:             if ($this->isNew() && null === $this->collFeatureI18ns) {
    2046:                 // return empty collection
    2047:                 $this->initFeatureI18ns();
    2048:             } else {
    2049:                 $collFeatureI18ns = FeatureI18nQuery::create(null, $criteria)
    2050:                     ->filterByFeature($this)
    2051:                     ->find($con);
    2052:                 if (null !== $criteria) {
    2053:                     if (false !== $this->collFeatureI18nsPartial && count($collFeatureI18ns)) {
    2054:                       $this->initFeatureI18ns(false);
    2055:
    2056:                       foreach($collFeatureI18ns as $obj) {
    2057:                         if (false == $this->collFeatureI18ns->contains($obj)) {
    2058:                           $this->collFeatureI18ns->append($obj);
    2059:                         }
    2060:                       }
    2061:
    2062:                       $this->collFeatureI18nsPartial = true;
    2063:                     }
    2064:
    2065:                     return $collFeatureI18ns;
    2066:                 }
    2067:
    2068:                 if($partial && $this->collFeatureI18ns) {
    2069:                     foreach($this->collFeatureI18ns as $obj) {
    2070:                         if($obj->isNew()) {
    2071:                             $collFeatureI18ns[] = $obj;
    2072:                         }
    2073:                     }
    2074:                 }
    2075:
    2076:                 $this->collFeatureI18ns = $collFeatureI18ns;
    2077:                 $this->collFeatureI18nsPartial = false;
    2078:             }
    2079:         }
    2080:
    2081:         return $this->collFeatureI18ns;
    2082:     }
    2083:
    2084:     /**
    2085:      * Sets a collection of FeatureI18n objects related by a one-to-many relationship
    2086:      * to the current object.
    2087:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    2088:      * and new objects from the given Propel collection.
    2089:      *
    2090:      * @param PropelCollection $featureI18ns A Propel collection.
    2091:      * @param PropelPDO $con Optional connection object
    2092:      */
    2093:     public function setFeatureI18ns(PropelCollection $featureI18ns, PropelPDO $con = null)
    2094:     {
    2095:         $this->featureI18nsScheduledForDeletion = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns);
    2096:
    2097:         foreach ($this->featureI18nsScheduledForDeletion as $featureI18nRemoved) {
    2098:             $featureI18nRemoved->setFeature(null);
    2099:         }
    2100:
    2101:         $this->collFeatureI18ns = null;
    2102:         foreach ($featureI18ns as $featureI18n) {
    2103:             $this->addFeatureI18n($featureI18n);
    2104:         }
    2105:
    2106:         $this->collFeatureI18ns = $featureI18ns;
    2107:         $this->collFeatureI18nsPartial = false;
    2108:     }
    2109:
    2110:     /**
    2111:      * Returns the number of related FeatureI18n objects.
    2112:      *
    2113:      * @param Criteria $criteria
    2114:      * @param boolean $distinct
    2115:      * @param PropelPDO $con
    2116:      * @return int             Count of related FeatureI18n objects.
    2117:      * @throws PropelException
    2118:      */
    2119:     public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    2120:     {
    2121:         $partial = $this->collFeatureI18nsPartial && !$this->isNew();
    2122:         if (null === $this->collFeatureI18ns || null !== $criteria || $partial) {
    2123:             if ($this->isNew() && null === $this->collFeatureI18ns) {
    2124:                 return 0;
    2125:             } else {
    2126:                 if($partial && !$criteria) {
    2127:                     return count($this->getFeatureI18ns());
    2128:                 }
    2129:                 $query = FeatureI18nQuery::create(null, $criteria);
    2130:                 if ($distinct) {
    2131:                     $query->distinct();
    2132:                 }
    2133:
    2134:                 return $query
    2135:                     ->filterByFeature($this)
    2136:                     ->count($con);
    2137:             }
    2138:         } else {
    2139:             return count($this->collFeatureI18ns);
    2140:         }
    2141:     }
    2142:
    2143:     /**
    2144:      * Method called to associate a FeatureI18n object to this object
    2145:      * through the FeatureI18n foreign key attribute.
    2146:      *
    2147:      * @param    FeatureI18n $l FeatureI18n
    2148:      * @return Feature The current object (for fluent API support)
    2149:      */
    2150:     public function addFeatureI18n(FeatureI18n $l)
    2151:     {
    2152:         if ($l && $locale = $l->getLocale()) {
    2153:             $this->setLocale($locale);
    2154:             $this->currentTranslations[$locale] = $l;
    2155:         }
    2156:         if ($this->collFeatureI18ns === null) {
    2157:             $this->initFeatureI18ns();
    2158:             $this->collFeatureI18nsPartial = true;
    2159:         }
    2160:         if (!$this->collFeatureI18ns->contains($l)) { // only add it if the **same** object is not already associated
    2161:             $this->doAddFeatureI18n($l);
    2162:         }
    2163:
    2164:         return $this;
    2165:     }
    2166:
    2167:     /**
    2168:      * @param   FeatureI18n $featureI18n The featureI18n object to add.
    2169:      */
    2170:     protected function doAddFeatureI18n($featureI18n)
    2171:     {
    2172:         $this->collFeatureI18ns[]= $featureI18n;
    2173:         $featureI18n->setFeature($this);
    2174:     }
    2175:
    2176:     /**
    2177:      * @param   FeatureI18n $featureI18n The featureI18n object to remove.
    2178:      */
    2179:     public function removeFeatureI18n($featureI18n)
    2180:     {
    2181:         if ($this->getFeatureI18ns()->contains($featureI18n)) {
    2182:             $this->collFeatureI18ns->remove($this->collFeatureI18ns->search($featureI18n));
    2183:             if (null === $this->featureI18nsScheduledForDeletion) {
    2184:                 $this->featureI18nsScheduledForDeletion = clone $this->collFeatureI18ns;
    2185:                 $this->featureI18nsScheduledForDeletion->clear();
    2186:             }
    2187:             $this->featureI18nsScheduledForDeletion[]= $featureI18n;
    2188:             $featureI18n->setFeature(null);
    2189:         }
    2190:     }
    2191:
    2192:     /**
    2193:      * Clears the current object and sets all attributes to their default values
    2194:      */
    2195:     public function clear()
    2196:     {
    2197:         $this->id = null;
    2198:         $this->visible = null;
    2199:         $this->position = null;
    2200:         $this->created_at = null;
    2201:         $this->updated_at = null;
    2202:         $this->alreadyInSave = false;
    2203:         $this->alreadyInValidation = false;
    2204:         $this->clearAllReferences();
    2205:         $this->applyDefaultValues();
    2206:         $this->resetModified();
    2207:         $this->setNew(true);
    2208:         $this->setDeleted(false);
    2209:     }
    2210:
    2211:     /**
    2212:      * Resets all references to other model objects or collections of model objects.
    2213:      *
    2214:      * This method is a user-space workaround for PHP's inability to garbage collect
    2215:      * objects with circular references (even in PHP 5.3). This is currently necessary
    2216:      * when using Propel in certain daemon or large-volumne/high-memory operations.
    2217:      *
    2218:      * @param boolean $deep Whether to also clear the references on all referrer objects.
    2219:      */
    2220:     public function clearAllReferences($deep = false)
    2221:     {
    2222:         if ($deep) {
    2223:             if ($this->collFeatureAvs) {
    2224:                 foreach ($this->collFeatureAvs as $o) {
    2225:                     $o->clearAllReferences($deep);
    2226:                 }
    2227:             }
    2228:             if ($this->collFeatureProds) {
    2229:                 foreach ($this->collFeatureProds as $o) {
    2230:                     $o->clearAllReferences($deep);
    2231:                 }
    2232:             }
    2233:             if ($this->collFeatureCategorys) {
    2234:                 foreach ($this->collFeatureCategorys as $o) {
    2235:                     $o->clearAllReferences($deep);
    2236:                 }
    2237:             }
    2238:             if ($this->collFeatureI18ns) {
    2239:                 foreach ($this->collFeatureI18ns as $o) {
    2240:                     $o->clearAllReferences($deep);
    2241:                 }
    2242:             }
    2243:         } // if ($deep)
    2244:
    2245:         // i18n behavior
    2246:         $this->currentLocale = 'en_EN';
    2247:         $this->currentTranslations = null;
    2248:
    2249:         if ($this->collFeatureAvs instanceof PropelCollection) {
    2250:             $this->collFeatureAvs->clearIterator();
    2251:         }
    2252:         $this->collFeatureAvs = null;
    2253:         if ($this->collFeatureProds instanceof PropelCollection) {
    2254:             $this->collFeatureProds->clearIterator();
    2255:         }
    2256:         $this->collFeatureProds = null;
    2257:         if ($this->collFeatureCategorys instanceof PropelCollection) {
    2258:             $this->collFeatureCategorys->clearIterator();
    2259:         }
    2260:         $this->collFeatureCategorys = null;
    2261:         if ($this->collFeatureI18ns instanceof PropelCollection) {
    2262:             $this->collFeatureI18ns->clearIterator();
    2263:         }
    2264:         $this->collFeatureI18ns = null;
    2265:     }
    2266:
    2267:     /**
    2268:      * return the string representation of this object
    2269:      *
    2270:      * @return string
    2271:      */
    2272:     public function __toString()
    2273:     {
    2274:         return (string) $this->exportTo(FeaturePeer::DEFAULT_STRING_FORMAT);
    2275:     }
    2276:
    2277:     /**
    2278:      * return true is the object is in saving state
    2279:      *
    2280:      * @return boolean
    2281:      */
    2282:     public function isAlreadyInSave()
    2283:     {
    2284:         return $this->alreadyInSave;
    2285:     }
    2286:
    2287:     // timestampable behavior
    2288:
    2289:     /**
    2290:      * Mark the current object so that the update date doesn't get updated during next save
    2291:      *
    2292:      * @return     Feature The current object (for fluent API support)
    2293:      */
    2294:     public function keepUpdateDateUnchanged()
    2295:     {
    2296:         $this->modifiedColumns[] = FeaturePeer::UPDATED_AT;
    2297:
    2298:         return $this;
    2299:     }
    2300:
    2301:     // i18n behavior
    2302:
    2303:     /**
    2304:      * Sets the locale for translations
    2305:      *
    2306:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2307:      *
    2308:      * @return    Feature The current object (for fluent API support)
    2309:      */
    2310:     public function setLocale($locale = 'en_EN')
    2311:     {
    2312:         $this->currentLocale = $locale;
    2313:
    2314:         return $this;
    2315:     }
    2316:
    2317:     /**
    2318:      * Gets the locale for translations
    2319:      *
    2320:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
    2321:      */
    2322:     public function getLocale()
    2323:     {
    2324:         return $this->currentLocale;
    2325:     }
    2326:
    2327:     /**
    2328:      * Returns the current translation for a given locale
    2329:      *
    2330:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2331:      * @param     PropelPDO $con an optional connection object
    2332:      *
    2333:      * @return FeatureI18n */
    2334:     public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
    2335:     {
    2336:         if (!isset($this->currentTranslations[$locale])) {
    2337:             if (null !== $this->collFeatureI18ns) {
    2338:                 foreach ($this->collFeatureI18ns as $translation) {
    2339:                     if ($translation->getLocale() == $locale) {
    2340:                         $this->currentTranslations[$locale] = $translation;
    2341:
    2342:                         return $translation;
    2343:                     }
    2344:                 }
    2345:             }
    2346:             if ($this->isNew()) {
    2347:                 $translation = new FeatureI18n();
    2348:                 $translation->setLocale($locale);
    2349:             } else {
    2350:                 $translation = FeatureI18nQuery::create()
    2351:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    2352:                     ->findOneOrCreate($con);
    2353:                 $this->currentTranslations[$locale] = $translation;
    2354:             }
    2355:             $this->addFeatureI18n($translation);
    2356:         }
    2357:
    2358:         return $this->currentTranslations[$locale];
    2359:     }
    2360:
    2361:     /**
    2362:      * Remove the translation for a given locale
    2363:      *
    2364:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2365:      * @param     PropelPDO $con an optional connection object
    2366:      *
    2367:      * @return    Feature The current object (for fluent API support)
    2368:      */
    2369:     public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
    2370:     {
    2371:         if (!$this->isNew()) {
    2372:             FeatureI18nQuery::create()
    2373:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    2374:                 ->delete($con);
    2375:         }
    2376:         if (isset($this->currentTranslations[$locale])) {
    2377:             unset($this->currentTranslations[$locale]);
    2378:         }
    2379:         foreach ($this->collFeatureI18ns as $key => $translation) {
    2380:             if ($translation->getLocale() == $locale) {
    2381:                 unset($this->collFeatureI18ns[$key]);
    2382:                 break;
    2383:             }
    2384:         }
    2385:
    2386:         return $this;
    2387:     }
    2388:
    2389:     /**
    2390:      * Returns the current translation
    2391:      *
    2392:      * @param     PropelPDO $con an optional connection object
    2393:      *
    2394:      * @return FeatureI18n */
    2395:     public function getCurrentTranslation(PropelPDO $con = null)
    2396:     {
    2397:         return $this->getTranslation($this->getLocale(), $con);
    2398:     }
    2399:
    2400:
    2401:         /**
    2402:          * Get the [title] column value.
    2403:          *
    2404:          * @return string
    2405:          */
    2406:         public function getTitle()
    2407:         {
    2408:         return $this->getCurrentTranslation()->getTitle();
    2409:     }
    2410:
    2411:
    2412:         /**
    2413:          * Set the value of [title] column.
    2414:          *
    2415:          * @param string $v new value
    2416:          * @return FeatureI18n The current object (for fluent API support)
    2417:          */
    2418:         public function setTitle($v)
    2419:         {    $this->getCurrentTranslation()->setTitle($v);
    2420:
    2421:         return $this;
    2422:     }
    2423:
    2424:
    2425:         /**
    2426:          * Get the [description] column value.
    2427:          *
    2428:          * @return string
    2429:          */
    2430:         public function getDescription()
    2431:         {
    2432:         return $this->getCurrentTranslation()->getDescription();
    2433:     }
    2434:
    2435:
    2436:         /**
    2437:          * Set the value of [description] column.
    2438:          *
    2439:          * @param string $v new value
    2440:          * @return FeatureI18n The current object (for fluent API support)
    2441:          */
    2442:         public function setDescription($v)
    2443:         {    $this->getCurrentTranslation()->setDescription($v);
    2444:
    2445:         return $this;
    2446:     }
    2447:
    2448:
    2449:         /**
    2450:          * Get the [chapo] column value.
    2451:          *
    2452:          * @return string
    2453:          */
    2454:         public function getChapo()
    2455:         {
    2456:         return $this->getCurrentTranslation()->getChapo();
    2457:     }
    2458:
    2459:
    2460:         /**
    2461:          * Set the value of [chapo] column.
    2462:          *
    2463:          * @param string $v new value
    2464:          * @return FeatureI18n The current object (for fluent API support)
    2465:          */
    2466:         public function setChapo($v)
    2467:         {    $this->getCurrentTranslation()->setChapo($v);
    2468:
    2469:         return $this;
    2470:     }
    2471:
    2472:
    2473:         /**
    2474:          * Get the [postscriptum] column value.
    2475:          *
    2476:          * @return string
    2477:          */
    2478:         public function getPostscriptum()
    2479:         {
    2480:         return $this->getCurrentTranslation()->getPostscriptum();
    2481:     }
    2482:
    2483:
    2484:         /**
    2485:          * Set the value of [postscriptum] column.
    2486:          *
    2487:          * @param string $v new value
    2488:          * @return FeatureI18n The current object (for fluent API support)
    2489:          */
    2490:         public function setPostscriptum($v)
    2491:         {    $this->getCurrentTranslation()->setPostscriptum($v);
    2492:
    2493:         return $this;
    2494:     }
    2495:
    2496: }
    2497: