Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

Classes

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