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

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