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