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