Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvDesc
  • BaseAttributeAvDescPeer
  • BaseAttributeAvDescQuery
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeDesc
  • BaseAttributeDescPeer
  • BaseAttributeDescQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryDesc
  • BaseCategoryDescPeer
  • BaseCategoryDescQuery
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigDesc
  • BaseConfigDescPeer
  • BaseConfigDescQuery
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentDesc
  • BaseContentDescPeer
  • BaseContentDescQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryDesc
  • BaseCountryDescPeer
  • BaseCountryDescQuery
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleDesc
  • BaseCustomerTitleDescPeer
  • BaseCustomerTitleDescQuery
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentDesc
  • BaseDocumentDescPeer
  • BaseDocumentDescQuery
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvDesc
  • BaseFeatureAvDescPeer
  • BaseFeatureAvDescQuery
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureDesc
  • BaseFeatureDescPeer
  • BaseFeatureDescQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderDesc
  • BaseFolderDescPeer
  • BaseFolderDescQuery
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupDesc
  • BaseGroupDescPeer
  • BaseGroupDescQuery
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageDesc
  • BaseImageDescPeer
  • BaseImageDescQuery
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageDesc
  • BaseMessageDescPeer
  • BaseMessageDescQuery
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModuleDesc
  • BaseModuleDescPeer
  • BaseModuleDescQuery
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusDesc
  • BaseOrderStatusDescPeer
  • BaseOrderStatusDescQuery
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductDesc
  • BaseProductDescPeer
  • BaseProductDescQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceDesc
  • BaseResourceDescPeer
  • BaseResourceDescQuery
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxDesc
  • BaseTaxDescPeer
  • BaseTaxDescQuery
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleDesc
  • BaseTaxRuleDescPeer
  • BaseTaxRuleDescQuery
  • BaseTaxRuleI18n
  • BaseTaxRuleI18nPeer
  • BaseTaxRuleI18nQuery
  • BaseTaxRulePeer
  • BaseTaxRuleQuery
  • Overview
  • Namespace
  • Class
  • Tree
   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\Accessory;
  17: use Thelia\Model\AccessoryPeer;
  18: use Thelia\Model\AccessoryQuery;
  19: use Thelia\Model\Product;
  20: use Thelia\Model\ProductQuery;
  21: 
  22: /**
  23:  * Base class that represents a row from the 'accessory' table.
  24:  *
  25:  *
  26:  *
  27:  * @package    propel.generator.Thelia.Model.om
  28:  */
  29: abstract class BaseAccessory extends BaseObject implements Persistent
  30: {
  31:     /**
  32:      * Peer class name
  33:      */
  34:     const PEER = 'Thelia\\Model\\AccessoryPeer';
  35: 
  36:     /**
  37:      * The Peer class.
  38:      * Instance provides a convenient way of calling static methods on a class
  39:      * that calling code may not be able to identify.
  40:      * @var        AccessoryPeer
  41:      */
  42:     protected static $peer;
  43: 
  44:     /**
  45:      * The flag var to prevent infinit loop in deep copy
  46:      * @var       boolean
  47:      */
  48:     protected $startCopy = false;
  49: 
  50:     /**
  51:      * The value for the id field.
  52:      * @var        int
  53:      */
  54:     protected $id;
  55: 
  56:     /**
  57:      * The value for the product_id field.
  58:      * @var        int
  59:      */
  60:     protected $product_id;
  61: 
  62:     /**
  63:      * The value for the accessory field.
  64:      * @var        int
  65:      */
  66:     protected $accessory;
  67: 
  68:     /**
  69:      * The value for the position field.
  70:      * @var        int
  71:      */
  72:     protected $position;
  73: 
  74:     /**
  75:      * The value for the created_at field.
  76:      * @var        string
  77:      */
  78:     protected $created_at;
  79: 
  80:     /**
  81:      * The value for the updated_at field.
  82:      * @var        string
  83:      */
  84:     protected $updated_at;
  85: 
  86:     /**
  87:      * @var        Product
  88:      */
  89:     protected $aProductRelatedByProductId;
  90: 
  91:     /**
  92:      * @var        Product
  93:      */
  94:     protected $aProductRelatedByAccessory;
  95: 
  96:     /**
  97:      * Flag to prevent endless save loop, if this object is referenced
  98:      * by another object which falls in this transaction.
  99:      * @var        boolean
 100:      */
 101:     protected $alreadyInSave = false;
 102: 
 103:     /**
 104:      * Flag to prevent endless validation loop, if this object is referenced
 105:      * by another object which falls in this transaction.
 106:      * @var        boolean
 107:      */
 108:     protected $alreadyInValidation = false;
 109: 
 110:     /**
 111:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 112:      * @var        boolean
 113:      */
 114:     protected $alreadyInClearAllReferencesDeep = false;
 115: 
 116:     /**
 117:      * Get the [id] column value.
 118:      *
 119:      * @return int
 120:      */
 121:     public function getId()
 122:     {
 123:         return $this->id;
 124:     }
 125: 
 126:     /**
 127:      * Get the [product_id] column value.
 128:      *
 129:      * @return int
 130:      */
 131:     public function getProductId()
 132:     {
 133:         return $this->product_id;
 134:     }
 135: 
 136:     /**
 137:      * Get the [accessory] column value.
 138:      *
 139:      * @return int
 140:      */
 141:     public function getAccessory()
 142:     {
 143:         return $this->accessory;
 144:     }
 145: 
 146:     /**
 147:      * Get the [position] column value.
 148:      *
 149:      * @return int
 150:      */
 151:     public function getPosition()
 152:     {
 153:         return $this->position;
 154:     }
 155: 
 156:     /**
 157:      * Get the [optionally formatted] temporal [created_at] column value.
 158:      *
 159:      *
 160:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 161:      *               If format is null, then the raw DateTime object will be returned.
 162:      * @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
 163:      * @throws PropelException - if unable to parse/validate the date/time value.
 164:      */
 165:     public function getCreatedAt($format = 'Y-m-d H:i:s')
 166:     {
 167:         if ($this->created_at === null) {
 168:             return null;
 169:         }
 170: 
 171:         if ($this->created_at === '0000-00-00 00:00:00') {
 172:             // while technically this is not a default value of null,
 173:             // this seems to be closest in meaning.
 174:             return null;
 175:         }
 176: 
 177:         try {
 178:             $dt = new DateTime($this->created_at);
 179:         } catch (Exception $x) {
 180:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
 181:         }
 182: 
 183:         if ($format === null) {
 184:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 185:             return $dt;
 186:         }
 187: 
 188:         if (strpos($format, '%') !== false) {
 189:             return strftime($format, $dt->format('U'));
 190:         }
 191: 
 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:         }
 216: 
 217:         try {
 218:             $dt = new DateTime($this->updated_at);
 219:         } catch (Exception $x) {
 220:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
 221:         }
 222: 
 223:         if ($format === null) {
 224:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 225:             return $dt;
 226:         }
 227: 
 228:         if (strpos($format, '%') !== false) {
 229:             return strftime($format, $dt->format('U'));
 230:         }
 231: 
 232:         return $dt->format($format);
 233: 
 234:     }
 235: 
 236:     /**
 237:      * Set the value of [id] column.
 238:      *
 239:      * @param int $v new value
 240:      * @return Accessory The current object (for fluent API support)
 241:      */
 242:     public function setId($v)
 243:     {
 244:         if ($v !== null && is_numeric($v)) {
 245:             $v = (int) $v;
 246:         }
 247: 
 248:         if ($this->id !== $v) {
 249:             $this->id = $v;
 250:             $this->modifiedColumns[] = AccessoryPeer::ID;
 251:         }
 252: 
 253: 
 254:         return $this;
 255:     } // setId()
 256: 
 257:     /**
 258:      * Set the value of [product_id] column.
 259:      *
 260:      * @param int $v new value
 261:      * @return Accessory The current object (for fluent API support)
 262:      */
 263:     public function setProductId($v)
 264:     {
 265:         if ($v !== null && is_numeric($v)) {
 266:             $v = (int) $v;
 267:         }
 268: 
 269:         if ($this->product_id !== $v) {
 270:             $this->product_id = $v;
 271:             $this->modifiedColumns[] = AccessoryPeer::PRODUCT_ID;
 272:         }
 273: 
 274:         if ($this->aProductRelatedByProductId !== null && $this->aProductRelatedByProductId->getId() !== $v) {
 275:             $this->aProductRelatedByProductId = null;
 276:         }
 277: 
 278: 
 279:         return $this;
 280:     } // setProductId()
 281: 
 282:     /**
 283:      * Set the value of [accessory] column.
 284:      *
 285:      * @param int $v new value
 286:      * @return Accessory The current object (for fluent API support)
 287:      */
 288:     public function setAccessory($v)
 289:     {
 290:         if ($v !== null && is_numeric($v)) {
 291:             $v = (int) $v;
 292:         }
 293: 
 294:         if ($this->accessory !== $v) {
 295:             $this->accessory = $v;
 296:             $this->modifiedColumns[] = AccessoryPeer::ACCESSORY;
 297:         }
 298: 
 299:         if ($this->aProductRelatedByAccessory !== null && $this->aProductRelatedByAccessory->getId() !== $v) {
 300:             $this->aProductRelatedByAccessory = null;
 301:         }
 302: 
 303: 
 304:         return $this;
 305:     } // setAccessory()
 306: 
 307:     /**
 308:      * Set the value of [position] column.
 309:      *
 310:      * @param int $v new value
 311:      * @return Accessory The current object (for fluent API support)
 312:      */
 313:     public function setPosition($v)
 314:     {
 315:         if ($v !== null && is_numeric($v)) {
 316:             $v = (int) $v;
 317:         }
 318: 
 319:         if ($this->position !== $v) {
 320:             $this->position = $v;
 321:             $this->modifiedColumns[] = AccessoryPeer::POSITION;
 322:         }
 323: 
 324: 
 325:         return $this;
 326:     } // setPosition()
 327: 
 328:     /**
 329:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 330:      *
 331:      * @param mixed $v string, integer (timestamp), or DateTime value.
 332:      *               Empty strings are treated as null.
 333:      * @return Accessory The current object (for fluent API support)
 334:      */
 335:     public function setCreatedAt($v)
 336:     {
 337:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 338:         if ($this->created_at !== null || $dt !== null) {
 339:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 340:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 341:             if ($currentDateAsString !== $newDateAsString) {
 342:                 $this->created_at = $newDateAsString;
 343:                 $this->modifiedColumns[] = AccessoryPeer::CREATED_AT;
 344:             }
 345:         } // if either are not null
 346: 
 347: 
 348:         return $this;
 349:     } // setCreatedAt()
 350: 
 351:     /**
 352:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 353:      *
 354:      * @param mixed $v string, integer (timestamp), or DateTime value.
 355:      *               Empty strings are treated as null.
 356:      * @return Accessory The current object (for fluent API support)
 357:      */
 358:     public function setUpdatedAt($v)
 359:     {
 360:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 361:         if ($this->updated_at !== null || $dt !== null) {
 362:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 363:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 364:             if ($currentDateAsString !== $newDateAsString) {
 365:                 $this->updated_at = $newDateAsString;
 366:                 $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT;
 367:             }
 368:         } // if either are not null
 369: 
 370: 
 371:         return $this;
 372:     } // setUpdatedAt()
 373: 
 374:     /**
 375:      * Indicates whether the columns in this object are only set to default values.
 376:      *
 377:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 378:      * modified _and_ has some values set which are non-default.
 379:      *
 380:      * @return boolean Whether the columns in this object are only been set with default values.
 381:      */
 382:     public function hasOnlyDefaultValues()
 383:     {
 384:         // otherwise, everything was equal, so return true
 385:         return true;
 386:     } // hasOnlyDefaultValues()
 387: 
 388:     /**
 389:      * Hydrates (populates) the object variables with values from the database resultset.
 390:      *
 391:      * An offset (0-based "start column") is specified so that objects can be hydrated
 392:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 393:      * for results of JOIN queries where the resultset row includes columns from two or
 394:      * more tables.
 395:      *
 396:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 397:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 398:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 399:      * @return int             next starting column
 400:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 401:      */
 402:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 403:     {
 404:         try {
 405: 
 406:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 407:             $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
 408:             $this->accessory = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
 409:             $this->position = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
 410:             $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
 411:             $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 412:             $this->resetModified();
 413: 
 414:             $this->setNew(false);
 415: 
 416:             if ($rehydrate) {
 417:                 $this->ensureConsistency();
 418:             }
 419:             $this->postHydrate($row, $startcol, $rehydrate);
 420:             return $startcol + 6; // 6 = AccessoryPeer::NUM_HYDRATE_COLUMNS.
 421: 
 422:         } catch (Exception $e) {
 423:             throw new PropelException("Error populating Accessory object", $e);
 424:         }
 425:     }
 426: 
 427:     /**
 428:      * Checks and repairs the internal consistency of the object.
 429:      *
 430:      * This method is executed after an already-instantiated object is re-hydrated
 431:      * from the database.  It exists to check any foreign keys to make sure that
 432:      * the objects related to the current object are correct based on foreign key.
 433:      *
 434:      * You can override this method in the stub class, but you should always invoke
 435:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 436:      * in case your model changes.
 437:      *
 438:      * @throws PropelException
 439:      */
 440:     public function ensureConsistency()
 441:     {
 442: 
 443:         if ($this->aProductRelatedByProductId !== null && $this->product_id !== $this->aProductRelatedByProductId->getId()) {
 444:             $this->aProductRelatedByProductId = null;
 445:         }
 446:         if ($this->aProductRelatedByAccessory !== null && $this->accessory !== $this->aProductRelatedByAccessory->getId()) {
 447:             $this->aProductRelatedByAccessory = null;
 448:         }
 449:     } // ensureConsistency
 450: 
 451:     /**
 452:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 453:      *
 454:      * This will only work if the object has been saved and has a valid primary key set.
 455:      *
 456:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 457:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 458:      * @return void
 459:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 460:      */
 461:     public function reload($deep = false, PropelPDO $con = null)
 462:     {
 463:         if ($this->isDeleted()) {
 464:             throw new PropelException("Cannot reload a deleted object.");
 465:         }
 466: 
 467:         if ($this->isNew()) {
 468:             throw new PropelException("Cannot reload an unsaved object.");
 469:         }
 470: 
 471:         if ($con === null) {
 472:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 473:         }
 474: 
 475:         // We don't need to alter the object instance pool; we're just modifying this instance
 476:         // already in the pool.
 477: 
 478:         $stmt = AccessoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 479:         $row = $stmt->fetch(PDO::FETCH_NUM);
 480:         $stmt->closeCursor();
 481:         if (!$row) {
 482:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 483:         }
 484:         $this->hydrate($row, 0, true); // rehydrate
 485: 
 486:         if ($deep) {  // also de-associate any related objects?
 487: 
 488:             $this->aProductRelatedByProductId = null;
 489:             $this->aProductRelatedByAccessory = null;
 490:         } // if (deep)
 491:     }
 492: 
 493:     /**
 494:      * Removes this object from datastore and sets delete attribute.
 495:      *
 496:      * @param PropelPDO $con
 497:      * @return void
 498:      * @throws PropelException
 499:      * @throws Exception
 500:      * @see        BaseObject::setDeleted()
 501:      * @see        BaseObject::isDeleted()
 502:      */
 503:     public function delete(PropelPDO $con = null)
 504:     {
 505:         if ($this->isDeleted()) {
 506:             throw new PropelException("This object has already been deleted.");
 507:         }
 508: 
 509:         if ($con === null) {
 510:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 511:         }
 512: 
 513:         $con->beginTransaction();
 514:         try {
 515:             $deleteQuery = AccessoryQuery::create()
 516:                 ->filterByPrimaryKey($this->getPrimaryKey());
 517:             $ret = $this->preDelete($con);
 518:             if ($ret) {
 519:                 $deleteQuery->delete($con);
 520:                 $this->postDelete($con);
 521:                 $con->commit();
 522:                 $this->setDeleted(true);
 523:             } else {
 524:                 $con->commit();
 525:             }
 526:         } catch (Exception $e) {
 527:             $con->rollBack();
 528:             throw $e;
 529:         }
 530:     }
 531: 
 532:     /**
 533:      * Persists this object to the database.
 534:      *
 535:      * If the object is new, it inserts it; otherwise an update is performed.
 536:      * All modified related objects will also be persisted in the doSave()
 537:      * method.  This method wraps all precipitate database operations in a
 538:      * single transaction.
 539:      *
 540:      * @param PropelPDO $con
 541:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 542:      * @throws PropelException
 543:      * @throws Exception
 544:      * @see        doSave()
 545:      */
 546:     public function save(PropelPDO $con = null)
 547:     {
 548:         if ($this->isDeleted()) {
 549:             throw new PropelException("You cannot save an object that has been deleted.");
 550:         }
 551: 
 552:         if ($con === null) {
 553:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 554:         }
 555: 
 556:         $con->beginTransaction();
 557:         $isInsert = $this->isNew();
 558:         try {
 559:             $ret = $this->preSave($con);
 560:             if ($isInsert) {
 561:                 $ret = $ret && $this->preInsert($con);
 562:                 // timestampable behavior
 563:                 if (!$this->isColumnModified(AccessoryPeer::CREATED_AT)) {
 564:                     $this->setCreatedAt(time());
 565:                 }
 566:                 if (!$this->isColumnModified(AccessoryPeer::UPDATED_AT)) {
 567:                     $this->setUpdatedAt(time());
 568:                 }
 569:             } else {
 570:                 $ret = $ret && $this->preUpdate($con);
 571:                 // timestampable behavior
 572:                 if ($this->isModified() && !$this->isColumnModified(AccessoryPeer::UPDATED_AT)) {
 573:                     $this->setUpdatedAt(time());
 574:                 }
 575:             }
 576:             if ($ret) {
 577:                 $affectedRows = $this->doSave($con);
 578:                 if ($isInsert) {
 579:                     $this->postInsert($con);
 580:                 } else {
 581:                     $this->postUpdate($con);
 582:                 }
 583:                 $this->postSave($con);
 584:                 AccessoryPeer::addInstanceToPool($this);
 585:             } else {
 586:                 $affectedRows = 0;
 587:             }
 588:             $con->commit();
 589: 
 590:             return $affectedRows;
 591:         } catch (Exception $e) {
 592:             $con->rollBack();
 593:             throw $e;
 594:         }
 595:     }
 596: 
 597:     /**
 598:      * Performs the work of inserting or updating the row in the database.
 599:      *
 600:      * If the object is new, it inserts it; otherwise an update is performed.
 601:      * All related objects are also updated in this method.
 602:      *
 603:      * @param PropelPDO $con
 604:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 605:      * @throws PropelException
 606:      * @see        save()
 607:      */
 608:     protected function doSave(PropelPDO $con)
 609:     {
 610:         $affectedRows = 0; // initialize var to track total num of affected rows
 611:         if (!$this->alreadyInSave) {
 612:             $this->alreadyInSave = true;
 613: 
 614:             // We call the save method on the following object(s) if they
 615:             // were passed to this object by their coresponding set
 616:             // method.  This object relates to these object(s) by a
 617:             // foreign key reference.
 618: 
 619:             if ($this->aProductRelatedByProductId !== null) {
 620:                 if ($this->aProductRelatedByProductId->isModified() || $this->aProductRelatedByProductId->isNew()) {
 621:                     $affectedRows += $this->aProductRelatedByProductId->save($con);
 622:                 }
 623:                 $this->setProductRelatedByProductId($this->aProductRelatedByProductId);
 624:             }
 625: 
 626:             if ($this->aProductRelatedByAccessory !== null) {
 627:                 if ($this->aProductRelatedByAccessory->isModified() || $this->aProductRelatedByAccessory->isNew()) {
 628:                     $affectedRows += $this->aProductRelatedByAccessory->save($con);
 629:                 }
 630:                 $this->setProductRelatedByAccessory($this->aProductRelatedByAccessory);
 631:             }
 632: 
 633:             if ($this->isNew() || $this->isModified()) {
 634:                 // persist changes
 635:                 if ($this->isNew()) {
 636:                     $this->doInsert($con);
 637:                 } else {
 638:                     $this->doUpdate($con);
 639:                 }
 640:                 $affectedRows += 1;
 641:                 $this->resetModified();
 642:             }
 643: 
 644:             $this->alreadyInSave = false;
 645: 
 646:         }
 647: 
 648:         return $affectedRows;
 649:     } // doSave()
 650: 
 651:     /**
 652:      * Insert the row in the database.
 653:      *
 654:      * @param PropelPDO $con
 655:      *
 656:      * @throws PropelException
 657:      * @see        doSave()
 658:      */
 659:     protected function doInsert(PropelPDO $con)
 660:     {
 661:         $modifiedColumns = array();
 662:         $index = 0;
 663: 
 664: 
 665:          // check the columns in natural order for more readable SQL queries
 666:         if ($this->isColumnModified(AccessoryPeer::ID)) {
 667:             $modifiedColumns[':p' . $index++]  = '`id`';
 668:         }
 669:         if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) {
 670:             $modifiedColumns[':p' . $index++]  = '`product_id`';
 671:         }
 672:         if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) {
 673:             $modifiedColumns[':p' . $index++]  = '`accessory`';
 674:         }
 675:         if ($this->isColumnModified(AccessoryPeer::POSITION)) {
 676:             $modifiedColumns[':p' . $index++]  = '`position`';
 677:         }
 678:         if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) {
 679:             $modifiedColumns[':p' . $index++]  = '`created_at`';
 680:         }
 681:         if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) {
 682:             $modifiedColumns[':p' . $index++]  = '`updated_at`';
 683:         }
 684: 
 685:         $sql = sprintf(
 686:             'INSERT INTO `accessory` (%s) VALUES (%s)',
 687:             implode(', ', $modifiedColumns),
 688:             implode(', ', array_keys($modifiedColumns))
 689:         );
 690: 
 691:         try {
 692:             $stmt = $con->prepare($sql);
 693:             foreach ($modifiedColumns as $identifier => $columnName) {
 694:                 switch ($columnName) {
 695:                     case '`id`':
 696:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
 697:                         break;
 698:                     case '`product_id`':
 699:                         $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
 700:                         break;
 701:                     case '`accessory`':
 702:                         $stmt->bindValue($identifier, $this->accessory, PDO::PARAM_INT);
 703:                         break;
 704:                     case '`position`':
 705:                         $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
 706:                         break;
 707:                     case '`created_at`':
 708:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
 709:                         break;
 710:                     case '`updated_at`':
 711:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
 712:                         break;
 713:                 }
 714:             }
 715:             $stmt->execute();
 716:         } catch (Exception $e) {
 717:             Propel::log($e->getMessage(), Propel::LOG_ERR);
 718:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
 719:         }
 720: 
 721:         $this->setNew(false);
 722:     }
 723: 
 724:     /**
 725:      * Update the row in the database.
 726:      *
 727:      * @param PropelPDO $con
 728:      *
 729:      * @see        doSave()
 730:      */
 731:     protected function doUpdate(PropelPDO $con)
 732:     {
 733:         $selectCriteria = $this->buildPkeyCriteria();
 734:         $valuesCriteria = $this->buildCriteria();
 735:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
 736:     }
 737: 
 738:     /**
 739:      * Array of ValidationFailed objects.
 740:      * @var        array ValidationFailed[]
 741:      */
 742:     protected $validationFailures = array();
 743: 
 744:     /**
 745:      * Gets any ValidationFailed objects that resulted from last call to validate().
 746:      *
 747:      *
 748:      * @return array ValidationFailed[]
 749:      * @see        validate()
 750:      */
 751:     public function getValidationFailures()
 752:     {
 753:         return $this->validationFailures;
 754:     }
 755: 
 756:     /**
 757:      * Validates the objects modified field values and all objects related to this table.
 758:      *
 759:      * If $columns is either a column name or an array of column names
 760:      * only those columns are validated.
 761:      *
 762:      * @param mixed $columns Column name or an array of column names.
 763:      * @return boolean Whether all columns pass validation.
 764:      * @see        doValidate()
 765:      * @see        getValidationFailures()
 766:      */
 767:     public function validate($columns = null)
 768:     {
 769:         $res = $this->doValidate($columns);
 770:         if ($res === true) {
 771:             $this->validationFailures = array();
 772: 
 773:             return true;
 774:         }
 775: 
 776:         $this->validationFailures = $res;
 777: 
 778:         return false;
 779:     }
 780: 
 781:     /**
 782:      * This function performs the validation work for complex object models.
 783:      *
 784:      * In addition to checking the current object, all related objects will
 785:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
 786:      * an aggreagated array of ValidationFailed objects will be returned.
 787:      *
 788:      * @param array $columns Array of column names to validate.
 789:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
 790:      */
 791:     protected function doValidate($columns = null)
 792:     {
 793:         if (!$this->alreadyInValidation) {
 794:             $this->alreadyInValidation = true;
 795:             $retval = null;
 796: 
 797:             $failureMap = array();
 798: 
 799: 
 800:             // We call the validate method on the following object(s) if they
 801:             // were passed to this object by their coresponding set
 802:             // method.  This object relates to these object(s) by a
 803:             // foreign key reference.
 804: 
 805:             if ($this->aProductRelatedByProductId !== null) {
 806:                 if (!$this->aProductRelatedByProductId->validate($columns)) {
 807:                     $failureMap = array_merge($failureMap, $this->aProductRelatedByProductId->getValidationFailures());
 808:                 }
 809:             }
 810: 
 811:             if ($this->aProductRelatedByAccessory !== null) {
 812:                 if (!$this->aProductRelatedByAccessory->validate($columns)) {
 813:                     $failureMap = array_merge($failureMap, $this->aProductRelatedByAccessory->getValidationFailures());
 814:                 }
 815:             }
 816: 
 817: 
 818:             if (($retval = AccessoryPeer::doValidate($this, $columns)) !== true) {
 819:                 $failureMap = array_merge($failureMap, $retval);
 820:             }
 821: 
 822: 
 823: 
 824:             $this->alreadyInValidation = false;
 825:         }
 826: 
 827:         return (!empty($failureMap) ? $failureMap : true);
 828:     }
 829: 
 830:     /**
 831:      * Retrieves a field from the object by name passed in as a string.
 832:      *
 833:      * @param string $name name
 834:      * @param string $type The type of fieldname the $name is of:
 835:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
 836:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 837:      *               Defaults to BasePeer::TYPE_PHPNAME
 838:      * @return mixed Value of field.
 839:      */
 840:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
 841:     {
 842:         $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
 843:         $field = $this->getByPosition($pos);
 844: 
 845:         return $field;
 846:     }
 847: 
 848:     /**
 849:      * Retrieves a field from the object by Position as specified in the xml schema.
 850:      * Zero-based.
 851:      *
 852:      * @param int $pos position in xml schema
 853:      * @return mixed Value of field at $pos
 854:      */
 855:     public function getByPosition($pos)
 856:     {
 857:         switch ($pos) {
 858:             case 0:
 859:                 return $this->getId();
 860:                 break;
 861:             case 1:
 862:                 return $this->getProductId();
 863:                 break;
 864:             case 2:
 865:                 return $this->getAccessory();
 866:                 break;
 867:             case 3:
 868:                 return $this->getPosition();
 869:                 break;
 870:             case 4:
 871:                 return $this->getCreatedAt();
 872:                 break;
 873:             case 5:
 874:                 return $this->getUpdatedAt();
 875:                 break;
 876:             default:
 877:                 return null;
 878:                 break;
 879:         } // switch()
 880:     }
 881: 
 882:     /**
 883:      * Exports the object as an array.
 884:      *
 885:      * You can specify the key type of the array by passing one of the class
 886:      * type constants.
 887:      *
 888:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
 889:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 890:      *                    Defaults to BasePeer::TYPE_PHPNAME.
 891:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
 892:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
 893:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
 894:      *
 895:      * @return array an associative array containing the field names (as keys) and field values
 896:      */
 897:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 898:     {
 899:         if (isset($alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()])) {
 900:             return '*RECURSION*';
 901:         }
 902:         $alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()] = true;
 903:         $keys = AccessoryPeer::getFieldNames($keyType);
 904:         $result = array(
 905:             $keys[0] => $this->getId(),
 906:             $keys[1] => $this->getProductId(),
 907:             $keys[2] => $this->getAccessory(),
 908:             $keys[3] => $this->getPosition(),
 909:             $keys[4] => $this->getCreatedAt(),
 910:             $keys[5] => $this->getUpdatedAt(),
 911:         );
 912:         if ($includeForeignObjects) {
 913:             if (null !== $this->aProductRelatedByProductId) {
 914:                 $result['ProductRelatedByProductId'] = $this->aProductRelatedByProductId->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
 915:             }
 916:             if (null !== $this->aProductRelatedByAccessory) {
 917:                 $result['ProductRelatedByAccessory'] = $this->aProductRelatedByAccessory->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
 918:             }
 919:         }
 920: 
 921:         return $result;
 922:     }
 923: 
 924:     /**
 925:      * Sets a field from the object by name passed in as a string.
 926:      *
 927:      * @param string $name peer name
 928:      * @param mixed $value field value
 929:      * @param string $type The type of fieldname the $name is of:
 930:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
 931:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 932:      *                     Defaults to BasePeer::TYPE_PHPNAME
 933:      * @return void
 934:      */
 935:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
 936:     {
 937:         $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
 938: 
 939:         $this->setByPosition($pos, $value);
 940:     }
 941: 
 942:     /**
 943:      * Sets a field from the object by Position as specified in the xml schema.
 944:      * Zero-based.
 945:      *
 946:      * @param int $pos position in xml schema
 947:      * @param mixed $value field value
 948:      * @return void
 949:      */
 950:     public function setByPosition($pos, $value)
 951:     {
 952:         switch ($pos) {
 953:             case 0:
 954:                 $this->setId($value);
 955:                 break;
 956:             case 1:
 957:                 $this->setProductId($value);
 958:                 break;
 959:             case 2:
 960:                 $this->setAccessory($value);
 961:                 break;
 962:             case 3:
 963:                 $this->setPosition($value);
 964:                 break;
 965:             case 4:
 966:                 $this->setCreatedAt($value);
 967:                 break;
 968:             case 5:
 969:                 $this->setUpdatedAt($value);
 970:                 break;
 971:         } // switch()
 972:     }
 973: 
 974:     /**
 975:      * Populates the object using an array.
 976:      *
 977:      * This is particularly useful when populating an object from one of the
 978:      * request arrays (e.g. $_POST).  This method goes through the column
 979:      * names, checking to see whether a matching key exists in populated
 980:      * array. If so the setByName() method is called for that column.
 981:      *
 982:      * You can specify the key type of the array by additionally passing one
 983:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
 984:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 985:      * The default key type is the column's BasePeer::TYPE_PHPNAME
 986:      *
 987:      * @param array  $arr     An array to populate the object from.
 988:      * @param string $keyType The type of keys the array uses.
 989:      * @return void
 990:      */
 991:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 992:     {
 993:         $keys = AccessoryPeer::getFieldNames($keyType);
 994: 
 995:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
 996:         if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
 997:         if (array_key_exists($keys[2], $arr)) $this->setAccessory($arr[$keys[2]]);
 998:         if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
 999:         if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
1000:         if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
1001:     }
1002: 
1003:     /**
1004:      * Build a Criteria object containing the values of all modified columns in this object.
1005:      *
1006:      * @return Criteria The Criteria object containing all modified values.
1007:      */
1008:     public function buildCriteria()
1009:     {
1010:         $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1011: 
1012:         if ($this->isColumnModified(AccessoryPeer::ID)) $criteria->add(AccessoryPeer::ID, $this->id);
1013:         if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) $criteria->add(AccessoryPeer::PRODUCT_ID, $this->product_id);
1014:         if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) $criteria->add(AccessoryPeer::ACCESSORY, $this->accessory);
1015:         if ($this->isColumnModified(AccessoryPeer::POSITION)) $criteria->add(AccessoryPeer::POSITION, $this->position);
1016:         if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) $criteria->add(AccessoryPeer::CREATED_AT, $this->created_at);
1017:         if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) $criteria->add(AccessoryPeer::UPDATED_AT, $this->updated_at);
1018: 
1019:         return $criteria;
1020:     }
1021: 
1022:     /**
1023:      * Builds a Criteria object containing the primary key for this object.
1024:      *
1025:      * Unlike buildCriteria() this method includes the primary key values regardless
1026:      * of whether or not they have been modified.
1027:      *
1028:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1029:      */
1030:     public function buildPkeyCriteria()
1031:     {
1032:         $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1033:         $criteria->add(AccessoryPeer::ID, $this->id);
1034: 
1035:         return $criteria;
1036:     }
1037: 
1038:     /**
1039:      * Returns the primary key for this object (row).
1040:      * @return int
1041:      */
1042:     public function getPrimaryKey()
1043:     {
1044:         return $this->getId();
1045:     }
1046: 
1047:     /**
1048:      * Generic method to set the primary key (id column).
1049:      *
1050:      * @param  int $key Primary key.
1051:      * @return void
1052:      */
1053:     public function setPrimaryKey($key)
1054:     {
1055:         $this->setId($key);
1056:     }
1057: 
1058:     /**
1059:      * Returns true if the primary key for this object is null.
1060:      * @return boolean
1061:      */
1062:     public function isPrimaryKeyNull()
1063:     {
1064: 
1065:         return null === $this->getId();
1066:     }
1067: 
1068:     /**
1069:      * Sets contents of passed object to values from current object.
1070:      *
1071:      * If desired, this method can also make copies of all associated (fkey referrers)
1072:      * objects.
1073:      *
1074:      * @param object $copyObj An object of Accessory (or compatible) type.
1075:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1076:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1077:      * @throws PropelException
1078:      */
1079:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1080:     {
1081:         $copyObj->setProductId($this->getProductId());
1082:         $copyObj->setAccessory($this->getAccessory());
1083:         $copyObj->setPosition($this->getPosition());
1084:         $copyObj->setCreatedAt($this->getCreatedAt());
1085:         $copyObj->setUpdatedAt($this->getUpdatedAt());
1086: 
1087:         if ($deepCopy && !$this->startCopy) {
1088:             // important: temporarily setNew(false) because this affects the behavior of
1089:             // the getter/setter methods for fkey referrer objects.
1090:             $copyObj->setNew(false);
1091:             // store object hash to prevent cycle
1092:             $this->startCopy = true;
1093: 
1094:             //unflag object copy
1095:             $this->startCopy = false;
1096:         } // if ($deepCopy)
1097: 
1098:         if ($makeNew) {
1099:             $copyObj->setNew(true);
1100:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1101:         }
1102:     }
1103: 
1104:     /**
1105:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1106:      * It creates a new object filling in the simple attributes, but skipping any primary
1107:      * keys that are defined for the table.
1108:      *
1109:      * If desired, this method can also make copies of all associated (fkey referrers)
1110:      * objects.
1111:      *
1112:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1113:      * @return Accessory Clone of current object.
1114:      * @throws PropelException
1115:      */
1116:     public function copy($deepCopy = false)
1117:     {
1118:         // we use get_class(), because this might be a subclass
1119:         $clazz = get_class($this);
1120:         $copyObj = new $clazz();
1121:         $this->copyInto($copyObj, $deepCopy);
1122: 
1123:         return $copyObj;
1124:     }
1125: 
1126:     /**
1127:      * Returns a peer instance associated with this om.
1128:      *
1129:      * Since Peer classes are not to have any instance attributes, this method returns the
1130:      * same instance for all member of this class. The method could therefore
1131:      * be static, but this would prevent one from overriding the behavior.
1132:      *
1133:      * @return AccessoryPeer
1134:      */
1135:     public function getPeer()
1136:     {
1137:         if (self::$peer === null) {
1138:             self::$peer = new AccessoryPeer();
1139:         }
1140: 
1141:         return self::$peer;
1142:     }
1143: 
1144:     /**
1145:      * Declares an association between this object and a Product object.
1146:      *
1147:      * @param             Product $v
1148:      * @return Accessory The current object (for fluent API support)
1149:      * @throws PropelException
1150:      */
1151:     public function setProductRelatedByProductId(Product $v = null)
1152:     {
1153:         if ($v === null) {
1154:             $this->setProductId(NULL);
1155:         } else {
1156:             $this->setProductId($v->getId());
1157:         }
1158: 
1159:         $this->aProductRelatedByProductId = $v;
1160: 
1161:         // Add binding for other direction of this n:n relationship.
1162:         // If this object has already been added to the Product object, it will not be re-added.
1163:         if ($v !== null) {
1164:             $v->addAccessoryRelatedByProductId($this);
1165:         }
1166: 
1167: 
1168:         return $this;
1169:     }
1170: 
1171: 
1172:     /**
1173:      * Get the associated Product object
1174:      *
1175:      * @param PropelPDO $con Optional Connection object.
1176:      * @param $doQuery Executes a query to get the object if required
1177:      * @return Product The associated Product object.
1178:      * @throws PropelException
1179:      */
1180:     public function getProductRelatedByProductId(PropelPDO $con = null, $doQuery = true)
1181:     {
1182:         if ($this->aProductRelatedByProductId === null && ($this->product_id !== null) && $doQuery) {
1183:             $this->aProductRelatedByProductId = ProductQuery::create()->findPk($this->product_id, $con);
1184:             /* The following can be used additionally to
1185:                 guarantee the related object contains a reference
1186:                 to this object.  This level of coupling may, however, be
1187:                 undesirable since it could result in an only partially populated collection
1188:                 in the referenced object.
1189:                 $this->aProductRelatedByProductId->addAccessorysRelatedByProductId($this);
1190:              */
1191:         }
1192: 
1193:         return $this->aProductRelatedByProductId;
1194:     }
1195: 
1196:     /**
1197:      * Declares an association between this object and a Product object.
1198:      *
1199:      * @param             Product $v
1200:      * @return Accessory The current object (for fluent API support)
1201:      * @throws PropelException
1202:      */
1203:     public function setProductRelatedByAccessory(Product $v = null)
1204:     {
1205:         if ($v === null) {
1206:             $this->setAccessory(NULL);
1207:         } else {
1208:             $this->setAccessory($v->getId());
1209:         }
1210: 
1211:         $this->aProductRelatedByAccessory = $v;
1212: 
1213:         // Add binding for other direction of this n:n relationship.
1214:         // If this object has already been added to the Product object, it will not be re-added.
1215:         if ($v !== null) {
1216:             $v->addAccessoryRelatedByAccessory($this);
1217:         }
1218: 
1219: 
1220:         return $this;
1221:     }
1222: 
1223: 
1224:     /**
1225:      * Get the associated Product object
1226:      *
1227:      * @param PropelPDO $con Optional Connection object.
1228:      * @param $doQuery Executes a query to get the object if required
1229:      * @return Product The associated Product object.
1230:      * @throws PropelException
1231:      */
1232:     public function getProductRelatedByAccessory(PropelPDO $con = null, $doQuery = true)
1233:     {
1234:         if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null) && $doQuery) {
1235:             $this->aProductRelatedByAccessory = ProductQuery::create()->findPk($this->accessory, $con);
1236:             /* The following can be used additionally to
1237:                 guarantee the related object contains a reference
1238:                 to this object.  This level of coupling may, however, be
1239:                 undesirable since it could result in an only partially populated collection
1240:                 in the referenced object.
1241:                 $this->aProductRelatedByAccessory->addAccessorysRelatedByAccessory($this);
1242:              */
1243:         }
1244: 
1245:         return $this->aProductRelatedByAccessory;
1246:     }
1247: 
1248:     /**
1249:      * Clears the current object and sets all attributes to their default values
1250:      */
1251:     public function clear()
1252:     {
1253:         $this->id = null;
1254:         $this->product_id = null;
1255:         $this->accessory = null;
1256:         $this->position = null;
1257:         $this->created_at = null;
1258:         $this->updated_at = null;
1259:         $this->alreadyInSave = false;
1260:         $this->alreadyInValidation = false;
1261:         $this->alreadyInClearAllReferencesDeep = false;
1262:         $this->clearAllReferences();
1263:         $this->resetModified();
1264:         $this->setNew(true);
1265:         $this->setDeleted(false);
1266:     }
1267: 
1268:     /**
1269:      * Resets all references to other model objects or collections of model objects.
1270:      *
1271:      * This method is a user-space workaround for PHP's inability to garbage collect
1272:      * objects with circular references (even in PHP 5.3). This is currently necessary
1273:      * when using Propel in certain daemon or large-volumne/high-memory operations.
1274:      *
1275:      * @param boolean $deep Whether to also clear the references on all referrer objects.
1276:      */
1277:     public function clearAllReferences($deep = false)
1278:     {
1279:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
1280:             $this->alreadyInClearAllReferencesDeep = true;
1281:             if ($this->aProductRelatedByProductId instanceof Persistent) {
1282:               $this->aProductRelatedByProductId->clearAllReferences($deep);
1283:             }
1284:             if ($this->aProductRelatedByAccessory instanceof Persistent) {
1285:               $this->aProductRelatedByAccessory->clearAllReferences($deep);
1286:             }
1287: 
1288:             $this->alreadyInClearAllReferencesDeep = false;
1289:         } // if ($deep)
1290: 
1291:         $this->aProductRelatedByProductId = null;
1292:         $this->aProductRelatedByAccessory = null;
1293:     }
1294: 
1295:     /**
1296:      * return the string representation of this object
1297:      *
1298:      * @return string
1299:      */
1300:     public function __toString()
1301:     {
1302:         return (string) $this->exportTo(AccessoryPeer::DEFAULT_STRING_FORMAT);
1303:     }
1304: 
1305:     /**
1306:      * return true is the object is in saving state
1307:      *
1308:      * @return boolean
1309:      */
1310:     public function isAlreadyInSave()
1311:     {
1312:         return $this->alreadyInSave;
1313:     }
1314: 
1315:     // timestampable behavior
1316: 
1317:     /**
1318:      * Mark the current object so that the update date doesn't get updated during next save
1319:      *
1320:      * @return     Accessory The current object (for fluent API support)
1321:      */
1322:     public function keepUpdateDateUnchanged()
1323:     {
1324:         $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT;
1325: 
1326:         return $this;
1327:     }
1328: 
1329: }
1330: 
thelia API documentation generated by ApiGen 2.8.0