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