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 \PropelCollection;
  14: use \PropelDateTime;
  15: use \PropelException;
  16: use \PropelObjectCollection;
  17: use \PropelPDO;
  18: use Thelia\Model\Product;
  19: use Thelia\Model\ProductQuery;
  20: use Thelia\Model\TaxRule;
  21: use Thelia\Model\TaxRuleCountry;
  22: use Thelia\Model\TaxRuleCountryQuery;
  23: use Thelia\Model\TaxRuleI18n;
  24: use Thelia\Model\TaxRuleI18nQuery;
  25: use Thelia\Model\TaxRulePeer;
  26: use Thelia\Model\TaxRuleQuery;
  27: 
  28: /**
  29:  * Base class that represents a row from the 'tax_rule' table.
  30:  *
  31:  *
  32:  *
  33:  * @package    propel.generator.Thelia.Model.om
  34:  */
  35: abstract class BaseTaxRule extends BaseObject implements Persistent
  36: {
  37:     /**
  38:      * Peer class name
  39:      */
  40:     const PEER = 'Thelia\\Model\\TaxRulePeer';
  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        TaxRulePeer
  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 code field.
  64:      * @var        string
  65:      */
  66:     protected $code;
  67: 
  68:     /**
  69:      * The value for the title field.
  70:      * @var        string
  71:      */
  72:     protected $title;
  73: 
  74:     /**
  75:      * The value for the description field.
  76:      * @var        string
  77:      */
  78:     protected $description;
  79: 
  80:     /**
  81:      * The value for the created_at field.
  82:      * @var        string
  83:      */
  84:     protected $created_at;
  85: 
  86:     /**
  87:      * The value for the updated_at field.
  88:      * @var        string
  89:      */
  90:     protected $updated_at;
  91: 
  92:     /**
  93:      * @var        PropelObjectCollection|Product[] Collection to store aggregation of Product objects.
  94:      */
  95:     protected $collProducts;
  96:     protected $collProductsPartial;
  97: 
  98:     /**
  99:      * @var        PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects.
 100:      */
 101:     protected $collTaxRuleCountrys;
 102:     protected $collTaxRuleCountrysPartial;
 103: 
 104:     /**
 105:      * @var        PropelObjectCollection|TaxRuleI18n[] Collection to store aggregation of TaxRuleI18n objects.
 106:      */
 107:     protected $collTaxRuleI18ns;
 108:     protected $collTaxRuleI18nsPartial;
 109: 
 110:     /**
 111:      * Flag to prevent endless save loop, if this object is referenced
 112:      * by another object which falls in this transaction.
 113:      * @var        boolean
 114:      */
 115:     protected $alreadyInSave = false;
 116: 
 117:     /**
 118:      * Flag to prevent endless validation loop, if this object is referenced
 119:      * by another object which falls in this transaction.
 120:      * @var        boolean
 121:      */
 122:     protected $alreadyInValidation = false;
 123: 
 124:     // i18n behavior
 125: 
 126:     /**
 127:      * Current locale
 128:      * @var        string
 129:      */
 130:     protected $currentLocale = 'en_EN';
 131: 
 132:     /**
 133:      * Current translation objects
 134:      * @var        array[TaxRuleI18n]
 135:      */
 136:     protected $currentTranslations;
 137: 
 138:     /**
 139:      * An array of objects scheduled for deletion.
 140:      * @var     PropelObjectCollection
 141:      */
 142:     protected $productsScheduledForDeletion = null;
 143: 
 144:     /**
 145:      * An array of objects scheduled for deletion.
 146:      * @var     PropelObjectCollection
 147:      */
 148:     protected $taxRuleCountrysScheduledForDeletion = null;
 149: 
 150:     /**
 151:      * An array of objects scheduled for deletion.
 152:      * @var     PropelObjectCollection
 153:      */
 154:     protected $taxRuleI18nsScheduledForDeletion = null;
 155: 
 156:     /**
 157:      * Get the [id] column value.
 158:      *
 159:      * @return int
 160:      */
 161:     public function getId()
 162:     {
 163:         return $this->id;
 164:     }
 165: 
 166:     /**
 167:      * Get the [code] column value.
 168:      *
 169:      * @return string
 170:      */
 171:     public function getCode()
 172:     {
 173:         return $this->code;
 174:     }
 175: 
 176:     /**
 177:      * Get the [title] column value.
 178:      *
 179:      * @return string
 180:      */
 181:     public function getTitle()
 182:     {
 183:         return $this->title;
 184:     }
 185: 
 186:     /**
 187:      * Get the [description] column value.
 188:      *
 189:      * @return string
 190:      */
 191:     public function getDescription()
 192:     {
 193:         return $this->description;
 194:     }
 195: 
 196:     /**
 197:      * Get the [optionally formatted] temporal [created_at] column value.
 198:      *
 199:      *
 200:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 201:      *               If format is null, then the raw DateTime object will be returned.
 202:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
 203:      * @throws PropelException - if unable to parse/validate the date/time value.
 204:      */
 205:     public function getCreatedAt($format = 'Y-m-d H:i:s')
 206:     {
 207:         if ($this->created_at === null) {
 208:             return null;
 209:         }
 210: 
 211:         if ($this->created_at === '0000-00-00 00:00:00') {
 212:             // while technically this is not a default value of null,
 213:             // this seems to be closest in meaning.
 214:             return null;
 215:         } else {
 216:             try {
 217:                 $dt = new DateTime($this->created_at);
 218:             } catch (Exception $x) {
 219:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
 220:             }
 221:         }
 222: 
 223:         if ($format === null) {
 224:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 225:             return $dt;
 226:         } elseif (strpos($format, '%') !== false) {
 227:             return strftime($format, $dt->format('U'));
 228:         } else {
 229:             return $dt->format($format);
 230:         }
 231:     }
 232: 
 233:     /**
 234:      * Get the [optionally formatted] temporal [updated_at] column value.
 235:      *
 236:      *
 237:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 238:      *               If format is null, then the raw DateTime object will be returned.
 239:      * @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
 240:      * @throws PropelException - if unable to parse/validate the date/time value.
 241:      */
 242:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
 243:     {
 244:         if ($this->updated_at === null) {
 245:             return null;
 246:         }
 247: 
 248:         if ($this->updated_at === '0000-00-00 00:00:00') {
 249:             // while technically this is not a default value of null,
 250:             // this seems to be closest in meaning.
 251:             return null;
 252:         } else {
 253:             try {
 254:                 $dt = new DateTime($this->updated_at);
 255:             } catch (Exception $x) {
 256:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
 257:             }
 258:         }
 259: 
 260:         if ($format === null) {
 261:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 262:             return $dt;
 263:         } elseif (strpos($format, '%') !== false) {
 264:             return strftime($format, $dt->format('U'));
 265:         } else {
 266:             return $dt->format($format);
 267:         }
 268:     }
 269: 
 270:     /**
 271:      * Set the value of [id] column.
 272:      *
 273:      * @param int $v new value
 274:      * @return TaxRule The current object (for fluent API support)
 275:      */
 276:     public function setId($v)
 277:     {
 278:         if ($v !== null) {
 279:             $v = (int) $v;
 280:         }
 281: 
 282:         if ($this->id !== $v) {
 283:             $this->id = $v;
 284:             $this->modifiedColumns[] = TaxRulePeer::ID;
 285:         }
 286: 
 287: 
 288:         return $this;
 289:     } // setId()
 290: 
 291:     /**
 292:      * Set the value of [code] column.
 293:      *
 294:      * @param string $v new value
 295:      * @return TaxRule The current object (for fluent API support)
 296:      */
 297:     public function setCode($v)
 298:     {
 299:         if ($v !== null) {
 300:             $v = (string) $v;
 301:         }
 302: 
 303:         if ($this->code !== $v) {
 304:             $this->code = $v;
 305:             $this->modifiedColumns[] = TaxRulePeer::CODE;
 306:         }
 307: 
 308: 
 309:         return $this;
 310:     } // setCode()
 311: 
 312:     /**
 313:      * Set the value of [title] column.
 314:      *
 315:      * @param string $v new value
 316:      * @return TaxRule The current object (for fluent API support)
 317:      */
 318:     public function setTitle($v)
 319:     {
 320:         if ($v !== null) {
 321:             $v = (string) $v;
 322:         }
 323: 
 324:         if ($this->title !== $v) {
 325:             $this->title = $v;
 326:             $this->modifiedColumns[] = TaxRulePeer::TITLE;
 327:         }
 328: 
 329: 
 330:         return $this;
 331:     } // setTitle()
 332: 
 333:     /**
 334:      * Set the value of [description] column.
 335:      *
 336:      * @param string $v new value
 337:      * @return TaxRule The current object (for fluent API support)
 338:      */
 339:     public function setDescription($v)
 340:     {
 341:         if ($v !== null) {
 342:             $v = (string) $v;
 343:         }
 344: 
 345:         if ($this->description !== $v) {
 346:             $this->description = $v;
 347:             $this->modifiedColumns[] = TaxRulePeer::DESCRIPTION;
 348:         }
 349: 
 350: 
 351:         return $this;
 352:     } // setDescription()
 353: 
 354:     /**
 355:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
 356:      *
 357:      * @param mixed $v string, integer (timestamp), or DateTime value.
 358:      *               Empty strings are treated as null.
 359:      * @return TaxRule The current object (for fluent API support)
 360:      */
 361:     public function setCreatedAt($v)
 362:     {
 363:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 364:         if ($this->created_at !== null || $dt !== null) {
 365:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 366:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 367:             if ($currentDateAsString !== $newDateAsString) {
 368:                 $this->created_at = $newDateAsString;
 369:                 $this->modifiedColumns[] = TaxRulePeer::CREATED_AT;
 370:             }
 371:         } // if either are not null
 372: 
 373: 
 374:         return $this;
 375:     } // setCreatedAt()
 376: 
 377:     /**
 378:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
 379:      *
 380:      * @param mixed $v string, integer (timestamp), or DateTime value.
 381:      *               Empty strings are treated as null.
 382:      * @return TaxRule The current object (for fluent API support)
 383:      */
 384:     public function setUpdatedAt($v)
 385:     {
 386:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 387:         if ($this->updated_at !== null || $dt !== null) {
 388:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 389:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 390:             if ($currentDateAsString !== $newDateAsString) {
 391:                 $this->updated_at = $newDateAsString;
 392:                 $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT;
 393:             }
 394:         } // if either are not null
 395: 
 396: 
 397:         return $this;
 398:     } // setUpdatedAt()
 399: 
 400:     /**
 401:      * Indicates whether the columns in this object are only set to default values.
 402:      *
 403:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 404:      * modified _and_ has some values set which are non-default.
 405:      *
 406:      * @return boolean Whether the columns in this object are only been set with default values.
 407:      */
 408:     public function hasOnlyDefaultValues()
 409:     {
 410:         // otherwise, everything was equal, so return true
 411:         return true;
 412:     } // hasOnlyDefaultValues()
 413: 
 414:     /**
 415:      * Hydrates (populates) the object variables with values from the database resultset.
 416:      *
 417:      * An offset (0-based "start column") is specified so that objects can be hydrated
 418:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 419:      * for results of JOIN queries where the resultset row includes columns from two or
 420:      * more tables.
 421:      *
 422:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 423:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 424:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 425:      * @return int             next starting column
 426:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 427:      */
 428:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 429:     {
 430:         try {
 431: 
 432:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 433:             $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
 434:             $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
 435:             $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
 436:             $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
 437:             $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 438:             $this->resetModified();
 439: 
 440:             $this->setNew(false);
 441: 
 442:             if ($rehydrate) {
 443:                 $this->ensureConsistency();
 444:             }
 445: 
 446:             return $startcol + 6; // 6 = TaxRulePeer::NUM_HYDRATE_COLUMNS.
 447: 
 448:         } catch (Exception $e) {
 449:             throw new PropelException("Error populating TaxRule object", $e);
 450:         }
 451:     }
 452: 
 453:     /**
 454:      * Checks and repairs the internal consistency of the object.
 455:      *
 456:      * This method is executed after an already-instantiated object is re-hydrated
 457:      * from the database.  It exists to check any foreign keys to make sure that
 458:      * the objects related to the current object are correct based on foreign key.
 459:      *
 460:      * You can override this method in the stub class, but you should always invoke
 461:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 462:      * in case your model changes.
 463:      *
 464:      * @throws PropelException
 465:      */
 466:     public function ensureConsistency()
 467:     {
 468: 
 469:     } // ensureConsistency
 470: 
 471:     /**
 472:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 473:      *
 474:      * This will only work if the object has been saved and has a valid primary key set.
 475:      *
 476:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 477:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 478:      * @return void
 479:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 480:      */
 481:     public function reload($deep = false, PropelPDO $con = null)
 482:     {
 483:         if ($this->isDeleted()) {
 484:             throw new PropelException("Cannot reload a deleted object.");
 485:         }
 486: 
 487:         if ($this->isNew()) {
 488:             throw new PropelException("Cannot reload an unsaved object.");
 489:         }
 490: 
 491:         if ($con === null) {
 492:             $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
 493:         }
 494: 
 495:         // We don't need to alter the object instance pool; we're just modifying this instance
 496:         // already in the pool.
 497: 
 498:         $stmt = TaxRulePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 499:         $row = $stmt->fetch(PDO::FETCH_NUM);
 500:         $stmt->closeCursor();
 501:         if (!$row) {
 502:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 503:         }
 504:         $this->hydrate($row, 0, true); // rehydrate
 505: 
 506:         if ($deep) {  // also de-associate any related objects?
 507: 
 508:             $this->collProducts = null;
 509: 
 510:             $this->collTaxRuleCountrys = null;
 511: 
 512:             $this->collTaxRuleI18ns = null;
 513: 
 514:         } // if (deep)
 515:     }
 516: 
 517:     /**
 518:      * Removes this object from datastore and sets delete attribute.
 519:      *
 520:      * @param PropelPDO $con
 521:      * @return void
 522:      * @throws PropelException
 523:      * @throws Exception
 524:      * @see        BaseObject::setDeleted()
 525:      * @see        BaseObject::isDeleted()
 526:      */
 527:     public function delete(PropelPDO $con = null)
 528:     {
 529:         if ($this->isDeleted()) {
 530:             throw new PropelException("This object has already been deleted.");
 531:         }
 532: 
 533:         if ($con === null) {
 534:             $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 535:         }
 536: 
 537:         $con->beginTransaction();
 538:         try {
 539:             $deleteQuery = TaxRuleQuery::create()
 540:                 ->filterByPrimaryKey($this->getPrimaryKey());
 541:             $ret = $this->preDelete($con);
 542:             if ($ret) {
 543:                 $deleteQuery->delete($con);
 544:                 $this->postDelete($con);
 545:                 $con->commit();
 546:                 $this->setDeleted(true);
 547:             } else {
 548:                 $con->commit();
 549:             }
 550:         } catch (Exception $e) {
 551:             $con->rollBack();
 552:             throw $e;
 553:         }
 554:     }
 555: 
 556:     /**
 557:      * Persists this object to the database.
 558:      *
 559:      * If the object is new, it inserts it; otherwise an update is performed.
 560:      * All modified related objects will also be persisted in the doSave()
 561:      * method.  This method wraps all precipitate database operations in a
 562:      * single transaction.
 563:      *
 564:      * @param PropelPDO $con
 565:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 566:      * @throws PropelException
 567:      * @throws Exception
 568:      * @see        doSave()
 569:      */
 570:     public function save(PropelPDO $con = null)
 571:     {
 572:         if ($this->isDeleted()) {
 573:             throw new PropelException("You cannot save an object that has been deleted.");
 574:         }
 575: 
 576:         if ($con === null) {
 577:             $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 578:         }
 579: 
 580:         $con->beginTransaction();
 581:         $isInsert = $this->isNew();
 582:         try {
 583:             $ret = $this->preSave($con);
 584:             if ($isInsert) {
 585:                 $ret = $ret && $this->preInsert($con);
 586:                 // timestampable behavior
 587:                 if (!$this->isColumnModified(TaxRulePeer::CREATED_AT)) {
 588:                     $this->setCreatedAt(time());
 589:                 }
 590:                 if (!$this->isColumnModified(TaxRulePeer::UPDATED_AT)) {
 591:                     $this->setUpdatedAt(time());
 592:                 }
 593:             } else {
 594:                 $ret = $ret && $this->preUpdate($con);
 595:                 // timestampable behavior
 596:                 if ($this->isModified() && !$this->isColumnModified(TaxRulePeer::UPDATED_AT)) {
 597:                     $this->setUpdatedAt(time());
 598:                 }
 599:             }
 600:             if ($ret) {
 601:                 $affectedRows = $this->doSave($con);
 602:                 if ($isInsert) {
 603:                     $this->postInsert($con);
 604:                 } else {
 605:                     $this->postUpdate($con);
 606:                 }
 607:                 $this->postSave($con);
 608:                 TaxRulePeer::addInstanceToPool($this);
 609:             } else {
 610:                 $affectedRows = 0;
 611:             }
 612:             $con->commit();
 613: 
 614:             return $affectedRows;
 615:         } catch (Exception $e) {
 616:             $con->rollBack();
 617:             throw $e;
 618:         }
 619:     }
 620: 
 621:     /**
 622:      * Performs the work of inserting or updating the row in the database.
 623:      *
 624:      * If the object is new, it inserts it; otherwise an update is performed.
 625:      * All related objects are also updated in this method.
 626:      *
 627:      * @param PropelPDO $con
 628:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 629:      * @throws PropelException
 630:      * @see        save()
 631:      */
 632:     protected function doSave(PropelPDO $con)
 633:     {
 634:         $affectedRows = 0; // initialize var to track total num of affected rows
 635:         if (!$this->alreadyInSave) {
 636:             $this->alreadyInSave = true;
 637: 
 638:             if ($this->isNew() || $this->isModified()) {
 639:                 // persist changes
 640:                 if ($this->isNew()) {
 641:                     $this->doInsert($con);
 642:                 } else {
 643:                     $this->doUpdate($con);
 644:                 }
 645:                 $affectedRows += 1;
 646:                 $this->resetModified();
 647:             }
 648: 
 649:             if ($this->productsScheduledForDeletion !== null) {
 650:                 if (!$this->productsScheduledForDeletion->isEmpty()) {
 651:                     foreach ($this->productsScheduledForDeletion as $product) {
 652:                         // need to save related object because we set the relation to null
 653:                         $product->save($con);
 654:                     }
 655:                     $this->productsScheduledForDeletion = null;
 656:                 }
 657:             }
 658: 
 659:             if ($this->collProducts !== null) {
 660:                 foreach ($this->collProducts as $referrerFK) {
 661:                     if (!$referrerFK->isDeleted()) {
 662:                         $affectedRows += $referrerFK->save($con);
 663:                     }
 664:                 }
 665:             }
 666: 
 667:             if ($this->taxRuleCountrysScheduledForDeletion !== null) {
 668:                 if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) {
 669:                     foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) {
 670:                         // need to save related object because we set the relation to null
 671:                         $taxRuleCountry->save($con);
 672:                     }
 673:                     $this->taxRuleCountrysScheduledForDeletion = null;
 674:                 }
 675:             }
 676: 
 677:             if ($this->collTaxRuleCountrys !== null) {
 678:                 foreach ($this->collTaxRuleCountrys as $referrerFK) {
 679:                     if (!$referrerFK->isDeleted()) {
 680:                         $affectedRows += $referrerFK->save($con);
 681:                     }
 682:                 }
 683:             }
 684: 
 685:             if ($this->taxRuleI18nsScheduledForDeletion !== null) {
 686:                 if (!$this->taxRuleI18nsScheduledForDeletion->isEmpty()) {
 687:                     TaxRuleI18nQuery::create()
 688:                         ->filterByPrimaryKeys($this->taxRuleI18nsScheduledForDeletion->getPrimaryKeys(false))
 689:                         ->delete($con);
 690:                     $this->taxRuleI18nsScheduledForDeletion = null;
 691:                 }
 692:             }
 693: 
 694:             if ($this->collTaxRuleI18ns !== null) {
 695:                 foreach ($this->collTaxRuleI18ns as $referrerFK) {
 696:                     if (!$referrerFK->isDeleted()) {
 697:                         $affectedRows += $referrerFK->save($con);
 698:                     }
 699:                 }
 700:             }
 701: 
 702:             $this->alreadyInSave = false;
 703: 
 704:         }
 705: 
 706:         return $affectedRows;
 707:     } // doSave()
 708: 
 709:     /**
 710:      * Insert the row in the database.
 711:      *
 712:      * @param PropelPDO $con
 713:      *
 714:      * @throws PropelException
 715:      * @see        doSave()
 716:      */
 717:     protected function doInsert(PropelPDO $con)
 718:     {
 719:         $modifiedColumns = array();
 720:         $index = 0;
 721: 
 722:         $this->modifiedColumns[] = TaxRulePeer::ID;
 723:         if (null !== $this->id) {
 724:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRulePeer::ID . ')');
 725:         }
 726: 
 727:          // check the columns in natural order for more readable SQL queries
 728:         if ($this->isColumnModified(TaxRulePeer::ID)) {
 729:             $modifiedColumns[':p' . $index++]  = '`ID`';
 730:         }
 731:         if ($this->isColumnModified(TaxRulePeer::CODE)) {
 732:             $modifiedColumns[':p' . $index++]  = '`CODE`';
 733:         }
 734:         if ($this->isColumnModified(TaxRulePeer::TITLE)) {
 735:             $modifiedColumns[':p' . $index++]  = '`TITLE`';
 736:         }
 737:         if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) {
 738:             $modifiedColumns[':p' . $index++]  = '`DESCRIPTION`';
 739:         }
 740:         if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) {
 741:             $modifiedColumns[':p' . $index++]  = '`CREATED_AT`';
 742:         }
 743:         if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) {
 744:             $modifiedColumns[':p' . $index++]  = '`UPDATED_AT`';
 745:         }
 746: 
 747:         $sql = sprintf(
 748:             'INSERT INTO `tax_rule` (%s) VALUES (%s)',
 749:             implode(', ', $modifiedColumns),
 750:             implode(', ', array_keys($modifiedColumns))
 751:         );
 752: 
 753:         try {
 754:             $stmt = $con->prepare($sql);
 755:             foreach ($modifiedColumns as $identifier => $columnName) {
 756:                 switch ($columnName) {
 757:                     case '`ID`':
 758:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
 759:                         break;
 760:                     case '`CODE`':
 761:                         $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
 762:                         break;
 763:                     case '`TITLE`':
 764:                         $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
 765:                         break;
 766:                     case '`DESCRIPTION`':
 767:                         $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
 768:                         break;
 769:                     case '`CREATED_AT`':
 770:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
 771:                         break;
 772:                     case '`UPDATED_AT`':
 773:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
 774:                         break;
 775:                 }
 776:             }
 777:             $stmt->execute();
 778:         } catch (Exception $e) {
 779:             Propel::log($e->getMessage(), Propel::LOG_ERR);
 780:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
 781:         }
 782: 
 783:         try {
 784:             $pk = $con->lastInsertId();
 785:         } catch (Exception $e) {
 786:             throw new PropelException('Unable to get autoincrement id.', $e);
 787:         }
 788:         $this->setId($pk);
 789: 
 790:         $this->setNew(false);
 791:     }
 792: 
 793:     /**
 794:      * Update the row in the database.
 795:      *
 796:      * @param PropelPDO $con
 797:      *
 798:      * @see        doSave()
 799:      */
 800:     protected function doUpdate(PropelPDO $con)
 801:     {
 802:         $selectCriteria = $this->buildPkeyCriteria();
 803:         $valuesCriteria = $this->buildCriteria();
 804:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
 805:     }
 806: 
 807:     /**
 808:      * Array of ValidationFailed objects.
 809:      * @var        array ValidationFailed[]
 810:      */
 811:     protected $validationFailures = array();
 812: 
 813:     /**
 814:      * Gets any ValidationFailed objects that resulted from last call to validate().
 815:      *
 816:      *
 817:      * @return array ValidationFailed[]
 818:      * @see        validate()
 819:      */
 820:     public function getValidationFailures()
 821:     {
 822:         return $this->validationFailures;
 823:     }
 824: 
 825:     /**
 826:      * Validates the objects modified field values and all objects related to this table.
 827:      *
 828:      * If $columns is either a column name or an array of column names
 829:      * only those columns are validated.
 830:      *
 831:      * @param mixed $columns Column name or an array of column names.
 832:      * @return boolean Whether all columns pass validation.
 833:      * @see        doValidate()
 834:      * @see        getValidationFailures()
 835:      */
 836:     public function validate($columns = null)
 837:     {
 838:         $res = $this->doValidate($columns);
 839:         if ($res === true) {
 840:             $this->validationFailures = array();
 841: 
 842:             return true;
 843:         } else {
 844:             $this->validationFailures = $res;
 845: 
 846:             return false;
 847:         }
 848:     }
 849: 
 850:     /**
 851:      * This function performs the validation work for complex object models.
 852:      *
 853:      * In addition to checking the current object, all related objects will
 854:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
 855:      * an aggreagated array of ValidationFailed objects will be returned.
 856:      *
 857:      * @param array $columns Array of column names to validate.
 858:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
 859:      */
 860:     protected function doValidate($columns = null)
 861:     {
 862:         if (!$this->alreadyInValidation) {
 863:             $this->alreadyInValidation = true;
 864:             $retval = null;
 865: 
 866:             $failureMap = array();
 867: 
 868: 
 869:             if (($retval = TaxRulePeer::doValidate($this, $columns)) !== true) {
 870:                 $failureMap = array_merge($failureMap, $retval);
 871:             }
 872: 
 873: 
 874:                 if ($this->collProducts !== null) {
 875:                     foreach ($this->collProducts as $referrerFK) {
 876:                         if (!$referrerFK->validate($columns)) {
 877:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
 878:                         }
 879:                     }
 880:                 }
 881: 
 882:                 if ($this->collTaxRuleCountrys !== null) {
 883:                     foreach ($this->collTaxRuleCountrys as $referrerFK) {
 884:                         if (!$referrerFK->validate($columns)) {
 885:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
 886:                         }
 887:                     }
 888:                 }
 889: 
 890:                 if ($this->collTaxRuleI18ns !== null) {
 891:                     foreach ($this->collTaxRuleI18ns as $referrerFK) {
 892:                         if (!$referrerFK->validate($columns)) {
 893:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
 894:                         }
 895:                     }
 896:                 }
 897: 
 898: 
 899:             $this->alreadyInValidation = false;
 900:         }
 901: 
 902:         return (!empty($failureMap) ? $failureMap : true);
 903:     }
 904: 
 905:     /**
 906:      * Retrieves a field from the object by name passed in as a string.
 907:      *
 908:      * @param string $name name
 909:      * @param string $type The type of fieldname the $name is of:
 910:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
 911:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 912:      *               Defaults to BasePeer::TYPE_PHPNAME
 913:      * @return mixed Value of field.
 914:      */
 915:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
 916:     {
 917:         $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
 918:         $field = $this->getByPosition($pos);
 919: 
 920:         return $field;
 921:     }
 922: 
 923:     /**
 924:      * Retrieves a field from the object by Position as specified in the xml schema.
 925:      * Zero-based.
 926:      *
 927:      * @param int $pos position in xml schema
 928:      * @return mixed Value of field at $pos
 929:      */
 930:     public function getByPosition($pos)
 931:     {
 932:         switch ($pos) {
 933:             case 0:
 934:                 return $this->getId();
 935:                 break;
 936:             case 1:
 937:                 return $this->getCode();
 938:                 break;
 939:             case 2:
 940:                 return $this->getTitle();
 941:                 break;
 942:             case 3:
 943:                 return $this->getDescription();
 944:                 break;
 945:             case 4:
 946:                 return $this->getCreatedAt();
 947:                 break;
 948:             case 5:
 949:                 return $this->getUpdatedAt();
 950:                 break;
 951:             default:
 952:                 return null;
 953:                 break;
 954:         } // switch()
 955:     }
 956: 
 957:     /**
 958:      * Exports the object as an array.
 959:      *
 960:      * You can specify the key type of the array by passing one of the class
 961:      * type constants.
 962:      *
 963:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
 964:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
 965:      *                    Defaults to BasePeer::TYPE_PHPNAME.
 966:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
 967:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
 968:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
 969:      *
 970:      * @return array an associative array containing the field names (as keys) and field values
 971:      */
 972:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 973:     {
 974:         if (isset($alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()])) {
 975:             return '*RECURSION*';
 976:         }
 977:         $alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()] = true;
 978:         $keys = TaxRulePeer::getFieldNames($keyType);
 979:         $result = array(
 980:             $keys[0] => $this->getId(),
 981:             $keys[1] => $this->getCode(),
 982:             $keys[2] => $this->getTitle(),
 983:             $keys[3] => $this->getDescription(),
 984:             $keys[4] => $this->getCreatedAt(),
 985:             $keys[5] => $this->getUpdatedAt(),
 986:         );
 987:         if ($includeForeignObjects) {
 988:             if (null !== $this->collProducts) {
 989:                 $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
 990:             }
 991:             if (null !== $this->collTaxRuleCountrys) {
 992:                 $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
 993:             }
 994:             if (null !== $this->collTaxRuleI18ns) {
 995:                 $result['TaxRuleI18ns'] = $this->collTaxRuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
 996:             }
 997:         }
 998: 
 999:         return $result;
1000:     }
1001: 
1002:     /**
1003:      * Sets a field from the object by name passed in as a string.
1004:      *
1005:      * @param string $name peer name
1006:      * @param mixed $value field value
1007:      * @param string $type The type of fieldname the $name is of:
1008:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1009:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1010:      *                     Defaults to BasePeer::TYPE_PHPNAME
1011:      * @return void
1012:      */
1013:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1014:     {
1015:         $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1016: 
1017:         $this->setByPosition($pos, $value);
1018:     }
1019: 
1020:     /**
1021:      * Sets a field from the object by Position as specified in the xml schema.
1022:      * Zero-based.
1023:      *
1024:      * @param int $pos position in xml schema
1025:      * @param mixed $value field value
1026:      * @return void
1027:      */
1028:     public function setByPosition($pos, $value)
1029:     {
1030:         switch ($pos) {
1031:             case 0:
1032:                 $this->setId($value);
1033:                 break;
1034:             case 1:
1035:                 $this->setCode($value);
1036:                 break;
1037:             case 2:
1038:                 $this->setTitle($value);
1039:                 break;
1040:             case 3:
1041:                 $this->setDescription($value);
1042:                 break;
1043:             case 4:
1044:                 $this->setCreatedAt($value);
1045:                 break;
1046:             case 5:
1047:                 $this->setUpdatedAt($value);
1048:                 break;
1049:         } // switch()
1050:     }
1051: 
1052:     /**
1053:      * Populates the object using an array.
1054:      *
1055:      * This is particularly useful when populating an object from one of the
1056:      * request arrays (e.g. $_POST).  This method goes through the column
1057:      * names, checking to see whether a matching key exists in populated
1058:      * array. If so the setByName() method is called for that column.
1059:      *
1060:      * You can specify the key type of the array by additionally passing one
1061:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1062:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1063:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1064:      *
1065:      * @param array  $arr     An array to populate the object from.
1066:      * @param string $keyType The type of keys the array uses.
1067:      * @return void
1068:      */
1069:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1070:     {
1071:         $keys = TaxRulePeer::getFieldNames($keyType);
1072: 
1073:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1074:         if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
1075:         if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
1076:         if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
1077:         if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
1078:         if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
1079:     }
1080: 
1081:     /**
1082:      * Build a Criteria object containing the values of all modified columns in this object.
1083:      *
1084:      * @return Criteria The Criteria object containing all modified values.
1085:      */
1086:     public function buildCriteria()
1087:     {
1088:         $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
1089: 
1090:         if ($this->isColumnModified(TaxRulePeer::ID)) $criteria->add(TaxRulePeer::ID, $this->id);
1091:         if ($this->isColumnModified(TaxRulePeer::CODE)) $criteria->add(TaxRulePeer::CODE, $this->code);
1092:         if ($this->isColumnModified(TaxRulePeer::TITLE)) $criteria->add(TaxRulePeer::TITLE, $this->title);
1093:         if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) $criteria->add(TaxRulePeer::DESCRIPTION, $this->description);
1094:         if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) $criteria->add(TaxRulePeer::CREATED_AT, $this->created_at);
1095:         if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) $criteria->add(TaxRulePeer::UPDATED_AT, $this->updated_at);
1096: 
1097:         return $criteria;
1098:     }
1099: 
1100:     /**
1101:      * Builds a Criteria object containing the primary key for this object.
1102:      *
1103:      * Unlike buildCriteria() this method includes the primary key values regardless
1104:      * of whether or not they have been modified.
1105:      *
1106:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1107:      */
1108:     public function buildPkeyCriteria()
1109:     {
1110:         $criteria = new Criteria(TaxRulePeer::DATABASE_NAME);
1111:         $criteria->add(TaxRulePeer::ID, $this->id);
1112: 
1113:         return $criteria;
1114:     }
1115: 
1116:     /**
1117:      * Returns the primary key for this object (row).
1118:      * @return int
1119:      */
1120:     public function getPrimaryKey()
1121:     {
1122:         return $this->getId();
1123:     }
1124: 
1125:     /**
1126:      * Generic method to set the primary key (id column).
1127:      *
1128:      * @param  int $key Primary key.
1129:      * @return void
1130:      */
1131:     public function setPrimaryKey($key)
1132:     {
1133:         $this->setId($key);
1134:     }
1135: 
1136:     /**
1137:      * Returns true if the primary key for this object is null.
1138:      * @return boolean
1139:      */
1140:     public function isPrimaryKeyNull()
1141:     {
1142: 
1143:         return null === $this->getId();
1144:     }
1145: 
1146:     /**
1147:      * Sets contents of passed object to values from current object.
1148:      *
1149:      * If desired, this method can also make copies of all associated (fkey referrers)
1150:      * objects.
1151:      *
1152:      * @param object $copyObj An object of TaxRule (or compatible) type.
1153:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1154:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1155:      * @throws PropelException
1156:      */
1157:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1158:     {
1159:         $copyObj->setCode($this->getCode());
1160:         $copyObj->setTitle($this->getTitle());
1161:         $copyObj->setDescription($this->getDescription());
1162:         $copyObj->setCreatedAt($this->getCreatedAt());
1163:         $copyObj->setUpdatedAt($this->getUpdatedAt());
1164: 
1165:         if ($deepCopy && !$this->startCopy) {
1166:             // important: temporarily setNew(false) because this affects the behavior of
1167:             // the getter/setter methods for fkey referrer objects.
1168:             $copyObj->setNew(false);
1169:             // store object hash to prevent cycle
1170:             $this->startCopy = true;
1171: 
1172:             foreach ($this->getProducts() as $relObj) {
1173:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1174:                     $copyObj->addProduct($relObj->copy($deepCopy));
1175:                 }
1176:             }
1177: 
1178:             foreach ($this->getTaxRuleCountrys() as $relObj) {
1179:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1180:                     $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
1181:                 }
1182:             }
1183: 
1184:             foreach ($this->getTaxRuleI18ns() as $relObj) {
1185:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1186:                     $copyObj->addTaxRuleI18n($relObj->copy($deepCopy));
1187:                 }
1188:             }
1189: 
1190:             //unflag object copy
1191:             $this->startCopy = false;
1192:         } // if ($deepCopy)
1193: 
1194:         if ($makeNew) {
1195:             $copyObj->setNew(true);
1196:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1197:         }
1198:     }
1199: 
1200:     /**
1201:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1202:      * It creates a new object filling in the simple attributes, but skipping any primary
1203:      * keys that are defined for the table.
1204:      *
1205:      * If desired, this method can also make copies of all associated (fkey referrers)
1206:      * objects.
1207:      *
1208:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1209:      * @return TaxRule Clone of current object.
1210:      * @throws PropelException
1211:      */
1212:     public function copy($deepCopy = false)
1213:     {
1214:         // we use get_class(), because this might be a subclass
1215:         $clazz = get_class($this);
1216:         $copyObj = new $clazz();
1217:         $this->copyInto($copyObj, $deepCopy);
1218: 
1219:         return $copyObj;
1220:     }
1221: 
1222:     /**
1223:      * Returns a peer instance associated with this om.
1224:      *
1225:      * Since Peer classes are not to have any instance attributes, this method returns the
1226:      * same instance for all member of this class. The method could therefore
1227:      * be static, but this would prevent one from overriding the behavior.
1228:      *
1229:      * @return TaxRulePeer
1230:      */
1231:     public function getPeer()
1232:     {
1233:         if (self::$peer === null) {
1234:             self::$peer = new TaxRulePeer();
1235:         }
1236: 
1237:         return self::$peer;
1238:     }
1239: 
1240: 
1241:     /**
1242:      * Initializes a collection based on the name of a relation.
1243:      * Avoids crafting an 'init[$relationName]s' method name
1244:      * that wouldn't work when StandardEnglishPluralizer is used.
1245:      *
1246:      * @param string $relationName The name of the relation to initialize
1247:      * @return void
1248:      */
1249:     public function initRelation($relationName)
1250:     {
1251:         if ('Product' == $relationName) {
1252:             $this->initProducts();
1253:         }
1254:         if ('TaxRuleCountry' == $relationName) {
1255:             $this->initTaxRuleCountrys();
1256:         }
1257:         if ('TaxRuleI18n' == $relationName) {
1258:             $this->initTaxRuleI18ns();
1259:         }
1260:     }
1261: 
1262:     /**
1263:      * Clears out the collProducts collection
1264:      *
1265:      * This does not modify the database; however, it will remove any associated objects, causing
1266:      * them to be refetched by subsequent calls to accessor method.
1267:      *
1268:      * @return void
1269:      * @see        addProducts()
1270:      */
1271:     public function clearProducts()
1272:     {
1273:         $this->collProducts = null; // important to set this to null since that means it is uninitialized
1274:         $this->collProductsPartial = null;
1275:     }
1276: 
1277:     /**
1278:      * reset is the collProducts collection loaded partially
1279:      *
1280:      * @return void
1281:      */
1282:     public function resetPartialProducts($v = true)
1283:     {
1284:         $this->collProductsPartial = $v;
1285:     }
1286: 
1287:     /**
1288:      * Initializes the collProducts collection.
1289:      *
1290:      * By default this just sets the collProducts collection to an empty array (like clearcollProducts());
1291:      * however, you may wish to override this method in your stub class to provide setting appropriate
1292:      * to your application -- for example, setting the initial array to the values stored in database.
1293:      *
1294:      * @param boolean $overrideExisting If set to true, the method call initializes
1295:      *                                        the collection even if it is not empty
1296:      *
1297:      * @return void
1298:      */
1299:     public function initProducts($overrideExisting = true)
1300:     {
1301:         if (null !== $this->collProducts && !$overrideExisting) {
1302:             return;
1303:         }
1304:         $this->collProducts = new PropelObjectCollection();
1305:         $this->collProducts->setModel('Product');
1306:     }
1307: 
1308:     /**
1309:      * Gets an array of Product objects which contain a foreign key that references this object.
1310:      *
1311:      * If the $criteria is not null, it is used to always fetch the results from the database.
1312:      * Otherwise the results are fetched from the database the first time, then cached.
1313:      * Next time the same method is called without $criteria, the cached collection is returned.
1314:      * If this TaxRule is new, it will return
1315:      * an empty collection or the current collection; the criteria is ignored on a new object.
1316:      *
1317:      * @param Criteria $criteria optional Criteria object to narrow the query
1318:      * @param PropelPDO $con optional connection object
1319:      * @return PropelObjectCollection|Product[] List of Product objects
1320:      * @throws PropelException
1321:      */
1322:     public function getProducts($criteria = null, PropelPDO $con = null)
1323:     {
1324:         $partial = $this->collProductsPartial && !$this->isNew();
1325:         if (null === $this->collProducts || null !== $criteria  || $partial) {
1326:             if ($this->isNew() && null === $this->collProducts) {
1327:                 // return empty collection
1328:                 $this->initProducts();
1329:             } else {
1330:                 $collProducts = ProductQuery::create(null, $criteria)
1331:                     ->filterByTaxRule($this)
1332:                     ->find($con);
1333:                 if (null !== $criteria) {
1334:                     if (false !== $this->collProductsPartial && count($collProducts)) {
1335:                       $this->initProducts(false);
1336: 
1337:                       foreach($collProducts as $obj) {
1338:                         if (false == $this->collProducts->contains($obj)) {
1339:                           $this->collProducts->append($obj);
1340:                         }
1341:                       }
1342: 
1343:                       $this->collProductsPartial = true;
1344:                     }
1345: 
1346:                     return $collProducts;
1347:                 }
1348: 
1349:                 if($partial && $this->collProducts) {
1350:                     foreach($this->collProducts as $obj) {
1351:                         if($obj->isNew()) {
1352:                             $collProducts[] = $obj;
1353:                         }
1354:                     }
1355:                 }
1356: 
1357:                 $this->collProducts = $collProducts;
1358:                 $this->collProductsPartial = false;
1359:             }
1360:         }
1361: 
1362:         return $this->collProducts;
1363:     }
1364: 
1365:     /**
1366:      * Sets a collection of Product objects related by a one-to-many relationship
1367:      * to the current object.
1368:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1369:      * and new objects from the given Propel collection.
1370:      *
1371:      * @param PropelCollection $products A Propel collection.
1372:      * @param PropelPDO $con Optional connection object
1373:      */
1374:     public function setProducts(PropelCollection $products, PropelPDO $con = null)
1375:     {
1376:         $this->productsScheduledForDeletion = $this->getProducts(new Criteria(), $con)->diff($products);
1377: 
1378:         foreach ($this->productsScheduledForDeletion as $productRemoved) {
1379:             $productRemoved->setTaxRule(null);
1380:         }
1381: 
1382:         $this->collProducts = null;
1383:         foreach ($products as $product) {
1384:             $this->addProduct($product);
1385:         }
1386: 
1387:         $this->collProducts = $products;
1388:         $this->collProductsPartial = false;
1389:     }
1390: 
1391:     /**
1392:      * Returns the number of related Product objects.
1393:      *
1394:      * @param Criteria $criteria
1395:      * @param boolean $distinct
1396:      * @param PropelPDO $con
1397:      * @return int             Count of related Product objects.
1398:      * @throws PropelException
1399:      */
1400:     public function countProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1401:     {
1402:         $partial = $this->collProductsPartial && !$this->isNew();
1403:         if (null === $this->collProducts || null !== $criteria || $partial) {
1404:             if ($this->isNew() && null === $this->collProducts) {
1405:                 return 0;
1406:             } else {
1407:                 if($partial && !$criteria) {
1408:                     return count($this->getProducts());
1409:                 }
1410:                 $query = ProductQuery::create(null, $criteria);
1411:                 if ($distinct) {
1412:                     $query->distinct();
1413:                 }
1414: 
1415:                 return $query
1416:                     ->filterByTaxRule($this)
1417:                     ->count($con);
1418:             }
1419:         } else {
1420:             return count($this->collProducts);
1421:         }
1422:     }
1423: 
1424:     /**
1425:      * Method called to associate a Product object to this object
1426:      * through the Product foreign key attribute.
1427:      *
1428:      * @param    Product $l Product
1429:      * @return TaxRule The current object (for fluent API support)
1430:      */
1431:     public function addProduct(Product $l)
1432:     {
1433:         if ($this->collProducts === null) {
1434:             $this->initProducts();
1435:             $this->collProductsPartial = true;
1436:         }
1437:         if (!$this->collProducts->contains($l)) { // only add it if the **same** object is not already associated
1438:             $this->doAddProduct($l);
1439:         }
1440: 
1441:         return $this;
1442:     }
1443: 
1444:     /**
1445:      * @param   Product $product The product object to add.
1446:      */
1447:     protected function doAddProduct($product)
1448:     {
1449:         $this->collProducts[]= $product;
1450:         $product->setTaxRule($this);
1451:     }
1452: 
1453:     /**
1454:      * @param   Product $product The product object to remove.
1455:      */
1456:     public function removeProduct($product)
1457:     {
1458:         if ($this->getProducts()->contains($product)) {
1459:             $this->collProducts->remove($this->collProducts->search($product));
1460:             if (null === $this->productsScheduledForDeletion) {
1461:                 $this->productsScheduledForDeletion = clone $this->collProducts;
1462:                 $this->productsScheduledForDeletion->clear();
1463:             }
1464:             $this->productsScheduledForDeletion[]= $product;
1465:             $product->setTaxRule(null);
1466:         }
1467:     }
1468: 
1469:     /**
1470:      * Clears out the collTaxRuleCountrys collection
1471:      *
1472:      * This does not modify the database; however, it will remove any associated objects, causing
1473:      * them to be refetched by subsequent calls to accessor method.
1474:      *
1475:      * @return void
1476:      * @see        addTaxRuleCountrys()
1477:      */
1478:     public function clearTaxRuleCountrys()
1479:     {
1480:         $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized
1481:         $this->collTaxRuleCountrysPartial = null;
1482:     }
1483: 
1484:     /**
1485:      * reset is the collTaxRuleCountrys collection loaded partially
1486:      *
1487:      * @return void
1488:      */
1489:     public function resetPartialTaxRuleCountrys($v = true)
1490:     {
1491:         $this->collTaxRuleCountrysPartial = $v;
1492:     }
1493: 
1494:     /**
1495:      * Initializes the collTaxRuleCountrys collection.
1496:      *
1497:      * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys());
1498:      * however, you may wish to override this method in your stub class to provide setting appropriate
1499:      * to your application -- for example, setting the initial array to the values stored in database.
1500:      *
1501:      * @param boolean $overrideExisting If set to true, the method call initializes
1502:      *                                        the collection even if it is not empty
1503:      *
1504:      * @return void
1505:      */
1506:     public function initTaxRuleCountrys($overrideExisting = true)
1507:     {
1508:         if (null !== $this->collTaxRuleCountrys && !$overrideExisting) {
1509:             return;
1510:         }
1511:         $this->collTaxRuleCountrys = new PropelObjectCollection();
1512:         $this->collTaxRuleCountrys->setModel('TaxRuleCountry');
1513:     }
1514: 
1515:     /**
1516:      * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object.
1517:      *
1518:      * If the $criteria is not null, it is used to always fetch the results from the database.
1519:      * Otherwise the results are fetched from the database the first time, then cached.
1520:      * Next time the same method is called without $criteria, the cached collection is returned.
1521:      * If this TaxRule is new, it will return
1522:      * an empty collection or the current collection; the criteria is ignored on a new object.
1523:      *
1524:      * @param Criteria $criteria optional Criteria object to narrow the query
1525:      * @param PropelPDO $con optional connection object
1526:      * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects
1527:      * @throws PropelException
1528:      */
1529:     public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null)
1530:     {
1531:         $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
1532:         if (null === $this->collTaxRuleCountrys || null !== $criteria  || $partial) {
1533:             if ($this->isNew() && null === $this->collTaxRuleCountrys) {
1534:                 // return empty collection
1535:                 $this->initTaxRuleCountrys();
1536:             } else {
1537:                 $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria)
1538:                     ->filterByTaxRule($this)
1539:                     ->find($con);
1540:                 if (null !== $criteria) {
1541:                     if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) {
1542:                       $this->initTaxRuleCountrys(false);
1543: 
1544:                       foreach($collTaxRuleCountrys as $obj) {
1545:                         if (false == $this->collTaxRuleCountrys->contains($obj)) {
1546:                           $this->collTaxRuleCountrys->append($obj);
1547:                         }
1548:                       }
1549: 
1550:                       $this->collTaxRuleCountrysPartial = true;
1551:                     }
1552: 
1553:                     return $collTaxRuleCountrys;
1554:                 }
1555: 
1556:                 if($partial && $this->collTaxRuleCountrys) {
1557:                     foreach($this->collTaxRuleCountrys as $obj) {
1558:                         if($obj->isNew()) {
1559:                             $collTaxRuleCountrys[] = $obj;
1560:                         }
1561:                     }
1562:                 }
1563: 
1564:                 $this->collTaxRuleCountrys = $collTaxRuleCountrys;
1565:                 $this->collTaxRuleCountrysPartial = false;
1566:             }
1567:         }
1568: 
1569:         return $this->collTaxRuleCountrys;
1570:     }
1571: 
1572:     /**
1573:      * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship
1574:      * to the current object.
1575:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1576:      * and new objects from the given Propel collection.
1577:      *
1578:      * @param PropelCollection $taxRuleCountrys A Propel collection.
1579:      * @param PropelPDO $con Optional connection object
1580:      */
1581:     public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null)
1582:     {
1583:         $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys);
1584: 
1585:         foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) {
1586:             $taxRuleCountryRemoved->setTaxRule(null);
1587:         }
1588: 
1589:         $this->collTaxRuleCountrys = null;
1590:         foreach ($taxRuleCountrys as $taxRuleCountry) {
1591:             $this->addTaxRuleCountry($taxRuleCountry);
1592:         }
1593: 
1594:         $this->collTaxRuleCountrys = $taxRuleCountrys;
1595:         $this->collTaxRuleCountrysPartial = false;
1596:     }
1597: 
1598:     /**
1599:      * Returns the number of related TaxRuleCountry objects.
1600:      *
1601:      * @param Criteria $criteria
1602:      * @param boolean $distinct
1603:      * @param PropelPDO $con
1604:      * @return int             Count of related TaxRuleCountry objects.
1605:      * @throws PropelException
1606:      */
1607:     public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1608:     {
1609:         $partial = $this->collTaxRuleCountrysPartial && !$this->isNew();
1610:         if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) {
1611:             if ($this->isNew() && null === $this->collTaxRuleCountrys) {
1612:                 return 0;
1613:             } else {
1614:                 if($partial && !$criteria) {
1615:                     return count($this->getTaxRuleCountrys());
1616:                 }
1617:                 $query = TaxRuleCountryQuery::create(null, $criteria);
1618:                 if ($distinct) {
1619:                     $query->distinct();
1620:                 }
1621: 
1622:                 return $query
1623:                     ->filterByTaxRule($this)
1624:                     ->count($con);
1625:             }
1626:         } else {
1627:             return count($this->collTaxRuleCountrys);
1628:         }
1629:     }
1630: 
1631:     /**
1632:      * Method called to associate a TaxRuleCountry object to this object
1633:      * through the TaxRuleCountry foreign key attribute.
1634:      *
1635:      * @param    TaxRuleCountry $l TaxRuleCountry
1636:      * @return TaxRule The current object (for fluent API support)
1637:      */
1638:     public function addTaxRuleCountry(TaxRuleCountry $l)
1639:     {
1640:         if ($this->collTaxRuleCountrys === null) {
1641:             $this->initTaxRuleCountrys();
1642:             $this->collTaxRuleCountrysPartial = true;
1643:         }
1644:         if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated
1645:             $this->doAddTaxRuleCountry($l);
1646:         }
1647: 
1648:         return $this;
1649:     }
1650: 
1651:     /**
1652:      * @param   TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
1653:      */
1654:     protected function doAddTaxRuleCountry($taxRuleCountry)
1655:     {
1656:         $this->collTaxRuleCountrys[]= $taxRuleCountry;
1657:         $taxRuleCountry->setTaxRule($this);
1658:     }
1659: 
1660:     /**
1661:      * @param   TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
1662:      */
1663:     public function removeTaxRuleCountry($taxRuleCountry)
1664:     {
1665:         if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) {
1666:             $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry));
1667:             if (null === $this->taxRuleCountrysScheduledForDeletion) {
1668:                 $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys;
1669:                 $this->taxRuleCountrysScheduledForDeletion->clear();
1670:             }
1671:             $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry;
1672:             $taxRuleCountry->setTaxRule(null);
1673:         }
1674:     }
1675: 
1676: 
1677:     /**
1678:      * If this collection has already been initialized with
1679:      * an identical criteria, it returns the collection.
1680:      * Otherwise if this TaxRule is new, it will return
1681:      * an empty collection; or if this TaxRule has previously
1682:      * been saved, it will retrieve related TaxRuleCountrys from storage.
1683:      *
1684:      * This method is protected by default in order to keep the public
1685:      * api reasonable.  You can provide public methods for those you
1686:      * actually need in TaxRule.
1687:      *
1688:      * @param Criteria $criteria optional Criteria object to narrow the query
1689:      * @param PropelPDO $con optional connection object
1690:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1691:      * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects
1692:      */
1693:     public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1694:     {
1695:         $query = TaxRuleCountryQuery::create(null, $criteria);
1696:         $query->joinWith('Tax', $join_behavior);
1697: 
1698:         return $this->getTaxRuleCountrys($query, $con);
1699:     }
1700: 
1701: 
1702:     /**
1703:      * If this collection has already been initialized with
1704:      * an identical criteria, it returns the collection.
1705:      * Otherwise if this TaxRule is new, it will return
1706:      * an empty collection; or if this TaxRule has previously
1707:      * been saved, it will retrieve related TaxRuleCountrys from storage.
1708:      *
1709:      * This method is protected by default in order to keep the public
1710:      * api reasonable.  You can provide public methods for those you
1711:      * actually need in TaxRule.
1712:      *
1713:      * @param Criteria $criteria optional Criteria object to narrow the query
1714:      * @param PropelPDO $con optional connection object
1715:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1716:      * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects
1717:      */
1718:     public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1719:     {
1720:         $query = TaxRuleCountryQuery::create(null, $criteria);
1721:         $query->joinWith('Country', $join_behavior);
1722: 
1723:         return $this->getTaxRuleCountrys($query, $con);
1724:     }
1725: 
1726:     /**
1727:      * Clears out the collTaxRuleI18ns collection
1728:      *
1729:      * This does not modify the database; however, it will remove any associated objects, causing
1730:      * them to be refetched by subsequent calls to accessor method.
1731:      *
1732:      * @return void
1733:      * @see        addTaxRuleI18ns()
1734:      */
1735:     public function clearTaxRuleI18ns()
1736:     {
1737:         $this->collTaxRuleI18ns = null; // important to set this to null since that means it is uninitialized
1738:         $this->collTaxRuleI18nsPartial = null;
1739:     }
1740: 
1741:     /**
1742:      * reset is the collTaxRuleI18ns collection loaded partially
1743:      *
1744:      * @return void
1745:      */
1746:     public function resetPartialTaxRuleI18ns($v = true)
1747:     {
1748:         $this->collTaxRuleI18nsPartial = $v;
1749:     }
1750: 
1751:     /**
1752:      * Initializes the collTaxRuleI18ns collection.
1753:      *
1754:      * By default this just sets the collTaxRuleI18ns collection to an empty array (like clearcollTaxRuleI18ns());
1755:      * however, you may wish to override this method in your stub class to provide setting appropriate
1756:      * to your application -- for example, setting the initial array to the values stored in database.
1757:      *
1758:      * @param boolean $overrideExisting If set to true, the method call initializes
1759:      *                                        the collection even if it is not empty
1760:      *
1761:      * @return void
1762:      */
1763:     public function initTaxRuleI18ns($overrideExisting = true)
1764:     {
1765:         if (null !== $this->collTaxRuleI18ns && !$overrideExisting) {
1766:             return;
1767:         }
1768:         $this->collTaxRuleI18ns = new PropelObjectCollection();
1769:         $this->collTaxRuleI18ns->setModel('TaxRuleI18n');
1770:     }
1771: 
1772:     /**
1773:      * Gets an array of TaxRuleI18n objects which contain a foreign key that references this object.
1774:      *
1775:      * If the $criteria is not null, it is used to always fetch the results from the database.
1776:      * Otherwise the results are fetched from the database the first time, then cached.
1777:      * Next time the same method is called without $criteria, the cached collection is returned.
1778:      * If this TaxRule is new, it will return
1779:      * an empty collection or the current collection; the criteria is ignored on a new object.
1780:      *
1781:      * @param Criteria $criteria optional Criteria object to narrow the query
1782:      * @param PropelPDO $con optional connection object
1783:      * @return PropelObjectCollection|TaxRuleI18n[] List of TaxRuleI18n objects
1784:      * @throws PropelException
1785:      */
1786:     public function getTaxRuleI18ns($criteria = null, PropelPDO $con = null)
1787:     {
1788:         $partial = $this->collTaxRuleI18nsPartial && !$this->isNew();
1789:         if (null === $this->collTaxRuleI18ns || null !== $criteria  || $partial) {
1790:             if ($this->isNew() && null === $this->collTaxRuleI18ns) {
1791:                 // return empty collection
1792:                 $this->initTaxRuleI18ns();
1793:             } else {
1794:                 $collTaxRuleI18ns = TaxRuleI18nQuery::create(null, $criteria)
1795:                     ->filterByTaxRule($this)
1796:                     ->find($con);
1797:                 if (null !== $criteria) {
1798:                     if (false !== $this->collTaxRuleI18nsPartial && count($collTaxRuleI18ns)) {
1799:                       $this->initTaxRuleI18ns(false);
1800: 
1801:                       foreach($collTaxRuleI18ns as $obj) {
1802:                         if (false == $this->collTaxRuleI18ns->contains($obj)) {
1803:                           $this->collTaxRuleI18ns->append($obj);
1804:                         }
1805:                       }
1806: 
1807:                       $this->collTaxRuleI18nsPartial = true;
1808:                     }
1809: 
1810:                     return $collTaxRuleI18ns;
1811:                 }
1812: 
1813:                 if($partial && $this->collTaxRuleI18ns) {
1814:                     foreach($this->collTaxRuleI18ns as $obj) {
1815:                         if($obj->isNew()) {
1816:                             $collTaxRuleI18ns[] = $obj;
1817:                         }
1818:                     }
1819:                 }
1820: 
1821:                 $this->collTaxRuleI18ns = $collTaxRuleI18ns;
1822:                 $this->collTaxRuleI18nsPartial = false;
1823:             }
1824:         }
1825: 
1826:         return $this->collTaxRuleI18ns;
1827:     }
1828: 
1829:     /**
1830:      * Sets a collection of TaxRuleI18n objects related by a one-to-many relationship
1831:      * to the current object.
1832:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1833:      * and new objects from the given Propel collection.
1834:      *
1835:      * @param PropelCollection $taxRuleI18ns A Propel collection.
1836:      * @param PropelPDO $con Optional connection object
1837:      */
1838:     public function setTaxRuleI18ns(PropelCollection $taxRuleI18ns, PropelPDO $con = null)
1839:     {
1840:         $this->taxRuleI18nsScheduledForDeletion = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns);
1841: 
1842:         foreach ($this->taxRuleI18nsScheduledForDeletion as $taxRuleI18nRemoved) {
1843:             $taxRuleI18nRemoved->setTaxRule(null);
1844:         }
1845: 
1846:         $this->collTaxRuleI18ns = null;
1847:         foreach ($taxRuleI18ns as $taxRuleI18n) {
1848:             $this->addTaxRuleI18n($taxRuleI18n);
1849:         }
1850: 
1851:         $this->collTaxRuleI18ns = $taxRuleI18ns;
1852:         $this->collTaxRuleI18nsPartial = false;
1853:     }
1854: 
1855:     /**
1856:      * Returns the number of related TaxRuleI18n objects.
1857:      *
1858:      * @param Criteria $criteria
1859:      * @param boolean $distinct
1860:      * @param PropelPDO $con
1861:      * @return int             Count of related TaxRuleI18n objects.
1862:      * @throws PropelException
1863:      */
1864:     public function countTaxRuleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1865:     {
1866:         $partial = $this->collTaxRuleI18nsPartial && !$this->isNew();
1867:         if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) {
1868:             if ($this->isNew() && null === $this->collTaxRuleI18ns) {
1869:                 return 0;
1870:             } else {
1871:                 if($partial && !$criteria) {
1872:                     return count($this->getTaxRuleI18ns());
1873:                 }
1874:                 $query = TaxRuleI18nQuery::create(null, $criteria);
1875:                 if ($distinct) {
1876:                     $query->distinct();
1877:                 }
1878: 
1879:                 return $query
1880:                     ->filterByTaxRule($this)
1881:                     ->count($con);
1882:             }
1883:         } else {
1884:             return count($this->collTaxRuleI18ns);
1885:         }
1886:     }
1887: 
1888:     /**
1889:      * Method called to associate a TaxRuleI18n object to this object
1890:      * through the TaxRuleI18n foreign key attribute.
1891:      *
1892:      * @param    TaxRuleI18n $l TaxRuleI18n
1893:      * @return TaxRule The current object (for fluent API support)
1894:      */
1895:     public function addTaxRuleI18n(TaxRuleI18n $l)
1896:     {
1897:         if ($l && $locale = $l->getLocale()) {
1898:             $this->setLocale($locale);
1899:             $this->currentTranslations[$locale] = $l;
1900:         }
1901:         if ($this->collTaxRuleI18ns === null) {
1902:             $this->initTaxRuleI18ns();
1903:             $this->collTaxRuleI18nsPartial = true;
1904:         }
1905:         if (!$this->collTaxRuleI18ns->contains($l)) { // only add it if the **same** object is not already associated
1906:             $this->doAddTaxRuleI18n($l);
1907:         }
1908: 
1909:         return $this;
1910:     }
1911: 
1912:     /**
1913:      * @param   TaxRuleI18n $taxRuleI18n The taxRuleI18n object to add.
1914:      */
1915:     protected function doAddTaxRuleI18n($taxRuleI18n)
1916:     {
1917:         $this->collTaxRuleI18ns[]= $taxRuleI18n;
1918:         $taxRuleI18n->setTaxRule($this);
1919:     }
1920: 
1921:     /**
1922:      * @param   TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove.
1923:      */
1924:     public function removeTaxRuleI18n($taxRuleI18n)
1925:     {
1926:         if ($this->getTaxRuleI18ns()->contains($taxRuleI18n)) {
1927:             $this->collTaxRuleI18ns->remove($this->collTaxRuleI18ns->search($taxRuleI18n));
1928:             if (null === $this->taxRuleI18nsScheduledForDeletion) {
1929:                 $this->taxRuleI18nsScheduledForDeletion = clone $this->collTaxRuleI18ns;
1930:                 $this->taxRuleI18nsScheduledForDeletion->clear();
1931:             }
1932:             $this->taxRuleI18nsScheduledForDeletion[]= $taxRuleI18n;
1933:             $taxRuleI18n->setTaxRule(null);
1934:         }
1935:     }
1936: 
1937:     /**
1938:      * Clears the current object and sets all attributes to their default values
1939:      */
1940:     public function clear()
1941:     {
1942:         $this->id = null;
1943:         $this->code = null;
1944:         $this->title = null;
1945:         $this->description = null;
1946:         $this->created_at = null;
1947:         $this->updated_at = null;
1948:         $this->alreadyInSave = false;
1949:         $this->alreadyInValidation = false;
1950:         $this->clearAllReferences();
1951:         $this->resetModified();
1952:         $this->setNew(true);
1953:         $this->setDeleted(false);
1954:     }
1955: 
1956:     /**
1957:      * Resets all references to other model objects or collections of model objects.
1958:      *
1959:      * This method is a user-space workaround for PHP's inability to garbage collect
1960:      * objects with circular references (even in PHP 5.3). This is currently necessary
1961:      * when using Propel in certain daemon or large-volumne/high-memory operations.
1962:      *
1963:      * @param boolean $deep Whether to also clear the references on all referrer objects.
1964:      */
1965:     public function clearAllReferences($deep = false)
1966:     {
1967:         if ($deep) {
1968:             if ($this->collProducts) {
1969:                 foreach ($this->collProducts as $o) {
1970:                     $o->clearAllReferences($deep);
1971:                 }
1972:             }
1973:             if ($this->collTaxRuleCountrys) {
1974:                 foreach ($this->collTaxRuleCountrys as $o) {
1975:                     $o->clearAllReferences($deep);
1976:                 }
1977:             }
1978:             if ($this->collTaxRuleI18ns) {
1979:                 foreach ($this->collTaxRuleI18ns as $o) {
1980:                     $o->clearAllReferences($deep);
1981:                 }
1982:             }
1983:         } // if ($deep)
1984: 
1985:         // i18n behavior
1986:         $this->currentLocale = 'en_EN';
1987:         $this->currentTranslations = null;
1988: 
1989:         if ($this->collProducts instanceof PropelCollection) {
1990:             $this->collProducts->clearIterator();
1991:         }
1992:         $this->collProducts = null;
1993:         if ($this->collTaxRuleCountrys instanceof PropelCollection) {
1994:             $this->collTaxRuleCountrys->clearIterator();
1995:         }
1996:         $this->collTaxRuleCountrys = null;
1997:         if ($this->collTaxRuleI18ns instanceof PropelCollection) {
1998:             $this->collTaxRuleI18ns->clearIterator();
1999:         }
2000:         $this->collTaxRuleI18ns = null;
2001:     }
2002: 
2003:     /**
2004:      * return the string representation of this object
2005:      *
2006:      * @return string
2007:      */
2008:     public function __toString()
2009:     {
2010:         return (string) $this->exportTo(TaxRulePeer::DEFAULT_STRING_FORMAT);
2011:     }
2012: 
2013:     /**
2014:      * return true is the object is in saving state
2015:      *
2016:      * @return boolean
2017:      */
2018:     public function isAlreadyInSave()
2019:     {
2020:         return $this->alreadyInSave;
2021:     }
2022: 
2023:     // timestampable behavior
2024: 
2025:     /**
2026:      * Mark the current object so that the update date doesn't get updated during next save
2027:      *
2028:      * @return     TaxRule The current object (for fluent API support)
2029:      */
2030:     public function keepUpdateDateUnchanged()
2031:     {
2032:         $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT;
2033: 
2034:         return $this;
2035:     }
2036: 
2037:     // i18n behavior
2038: 
2039:     /**
2040:      * Sets the locale for translations
2041:      *
2042:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2043:      *
2044:      * @return    TaxRule The current object (for fluent API support)
2045:      */
2046:     public function setLocale($locale = 'en_EN')
2047:     {
2048:         $this->currentLocale = $locale;
2049: 
2050:         return $this;
2051:     }
2052: 
2053:     /**
2054:      * Gets the locale for translations
2055:      *
2056:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
2057:      */
2058:     public function getLocale()
2059:     {
2060:         return $this->currentLocale;
2061:     }
2062: 
2063:     /**
2064:      * Returns the current translation for a given locale
2065:      *
2066:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2067:      * @param     PropelPDO $con an optional connection object
2068:      *
2069:      * @return TaxRuleI18n */
2070:     public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
2071:     {
2072:         if (!isset($this->currentTranslations[$locale])) {
2073:             if (null !== $this->collTaxRuleI18ns) {
2074:                 foreach ($this->collTaxRuleI18ns as $translation) {
2075:                     if ($translation->getLocale() == $locale) {
2076:                         $this->currentTranslations[$locale] = $translation;
2077: 
2078:                         return $translation;
2079:                     }
2080:                 }
2081:             }
2082:             if ($this->isNew()) {
2083:                 $translation = new TaxRuleI18n();
2084:                 $translation->setLocale($locale);
2085:             } else {
2086:                 $translation = TaxRuleI18nQuery::create()
2087:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2088:                     ->findOneOrCreate($con);
2089:                 $this->currentTranslations[$locale] = $translation;
2090:             }
2091:             $this->addTaxRuleI18n($translation);
2092:         }
2093: 
2094:         return $this->currentTranslations[$locale];
2095:     }
2096: 
2097:     /**
2098:      * Remove the translation for a given locale
2099:      *
2100:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2101:      * @param     PropelPDO $con an optional connection object
2102:      *
2103:      * @return    TaxRule The current object (for fluent API support)
2104:      */
2105:     public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
2106:     {
2107:         if (!$this->isNew()) {
2108:             TaxRuleI18nQuery::create()
2109:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2110:                 ->delete($con);
2111:         }
2112:         if (isset($this->currentTranslations[$locale])) {
2113:             unset($this->currentTranslations[$locale]);
2114:         }
2115:         foreach ($this->collTaxRuleI18ns as $key => $translation) {
2116:             if ($translation->getLocale() == $locale) {
2117:                 unset($this->collTaxRuleI18ns[$key]);
2118:                 break;
2119:             }
2120:         }
2121: 
2122:         return $this;
2123:     }
2124: 
2125:     /**
2126:      * Returns the current translation
2127:      *
2128:      * @param     PropelPDO $con an optional connection object
2129:      *
2130:      * @return TaxRuleI18n */
2131:     public function getCurrentTranslation(PropelPDO $con = null)
2132:     {
2133:         return $this->getTranslation($this->getLocale(), $con);
2134:     }
2135: 
2136: }
2137: 
thelia API documentation generated by ApiGen 2.8.0