Overview

Namespaces

  • Thelia
    • Action
    • Config
    • Controller
    • Core
      • Bundle
      • DependencyInjection
        • Compiler
        • Loader
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Element
        • Loop
        • TestLoop
      • Event
      • Exception
      • Filter
      • Tokenizer

Classes

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