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