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