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