# File core/lib/Thelia/Model/om/BaseTaxRuleCountry.php | thelia

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