Overview

Namespaces

  • PHP
  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools

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