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