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 $alreadyInClearAllReferencesDeep = false;
236:
237: 238: 239: 240:
241: protected $addresssScheduledForDeletion = null;
242:
243: 244: 245: 246:
247: protected = null;
248:
249: 250: 251: 252: 253:
254: public function getId()
255: {
256: return $this->id;
257: }
258:
259: 260: 261: 262: 263:
264: public function getRef()
265: {
266: return $this->ref;
267: }
268:
269: 270: 271: 272: 273:
274: public function getCustomerTitleId()
275: {
276: return $this->customer_title_id;
277: }
278:
279: 280: 281: 282: 283:
284: public function getCompany()
285: {
286: return $this->company;
287: }
288:
289: 290: 291: 292: 293:
294: public function getFirstname()
295: {
296: return $this->firstname;
297: }
298:
299: 300: 301: 302: 303:
304: public function getLastname()
305: {
306: return $this->lastname;
307: }
308:
309: 310: 311: 312: 313:
314: public function getAddress1()
315: {
316: return $this->address1;
317: }
318:
319: 320: 321: 322: 323:
324: public function getAddress2()
325: {
326: return $this->address2;
327: }
328:
329: 330: 331: 332: 333:
334: public function getAddress3()
335: {
336: return $this->address3;
337: }
338:
339: 340: 341: 342: 343:
344: public function getZipcode()
345: {
346: return $this->zipcode;
347: }
348:
349: 350: 351: 352: 353:
354: public function getCity()
355: {
356: return $this->city;
357: }
358:
359: 360: 361: 362: 363:
364: public function getCountryId()
365: {
366: return $this->country_id;
367: }
368:
369: 370: 371: 372: 373:
374: public function getPhone()
375: {
376: return $this->phone;
377: }
378:
379: 380: 381: 382: 383:
384: public function getCellphone()
385: {
386: return $this->cellphone;
387: }
388:
389: 390: 391: 392: 393:
394: public function getEmail()
395: {
396: return $this->email;
397: }
398:
399: 400: 401: 402: 403:
404: public function getPassword()
405: {
406: return $this->password;
407: }
408:
409: 410: 411: 412: 413:
414: public function getAlgo()
415: {
416: return $this->algo;
417: }
418:
419: 420: 421: 422: 423:
424: public function getSalt()
425: {
426: return $this->salt;
427: }
428:
429: 430: 431: 432: 433:
434: public function getReseller()
435: {
436: return $this->reseller;
437: }
438:
439: 440: 441: 442: 443:
444: public function getLang()
445: {
446: return $this->lang;
447: }
448:
449: 450: 451: 452: 453:
454: public function ()
455: {
456: return $this->sponsor;
457: }
458:
459: 460: 461: 462: 463:
464: public function getDiscount()
465: {
466: return $this->discount;
467: }
468:
469: 470: 471: 472: 473: 474: 475: 476: 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:
486:
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:
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: 511: 512: 513: 514: 515: 516: 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:
526:
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:
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: 551: 552: 553: 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: }
569:
570: 571: 572: 573: 574: 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: }
590:
591: 592: 593: 594: 595: 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: }
615:
616: 617: 618: 619: 620: 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: }
636:
637: 638: 639: 640: 641: 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: }
657:
658: 659: 660: 661: 662: 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: }
678:
679: 680: 681: 682: 683: 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: }
699:
700: 701: 702: 703: 704: 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: }
720:
721: 722: 723: 724: 725: 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: }
741:
742: 743: 744: 745: 746: 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: }
762:
763: 764: 765: 766: 767: 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: }
783:
784: 785: 786: 787: 788: 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: }
804:
805: 806: 807: 808: 809: 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: }
825:
826: 827: 828: 829: 830: 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: }
846:
847: 848: 849: 850: 851: 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: }
867:
868: 869: 870: 871: 872: 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: }
888:
889: 890: 891: 892: 893: 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: }
909:
910: 911: 912: 913: 914: 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: }
930:
931: 932: 933: 934: 935: 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: }
951:
952: 953: 954: 955: 956: 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: }
972:
973: 974: 975: 976: 977: 978:
979: public function ($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: }
993:
994: 995: 996: 997: 998: 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: }
1014:
1015: 1016: 1017: 1018: 1019: 1020: 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: }
1033:
1034:
1035: return $this;
1036: }
1037:
1038: 1039: 1040: 1041: 1042: 1043: 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: }
1056:
1057:
1058: return $this;
1059: }
1060:
1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068:
1069: public function hasOnlyDefaultValues()
1070: {
1071:
1072: return true;
1073: }
1074:
1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 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;
1126:
1127: } catch (Exception $e) {
1128: throw new PropelException("Error populating Customer object", $e);
1129: }
1130: }
1131:
1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 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: }
1152:
1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 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:
1178:
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);
1187:
1188: if ($deep) {
1189:
1190: $this->aCustomerTitle = null;
1191: $this->collAddresss = null;
1192:
1193: $this->collOrders = null;
1194:
1195: }
1196: }
1197:
1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 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: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 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:
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:
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: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312:
1313: protected function doSave(PropelPDO $con)
1314: {
1315: $affectedRows = 0;
1316: if (!$this->alreadyInSave) {
1317: $this->alreadyInSave = true;
1318:
1319:
1320:
1321:
1322:
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:
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: }
1382:
1383: 1384: 1385: 1386: 1387: 1388: 1389: 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:
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: 1577: 1578: 1579: 1580: 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: 1591: 1592:
1593: protected $validationFailures = array();
1594:
1595: 1596: 1597: 1598: 1599: 1600: 1601:
1602: public function getValidationFailures()
1603: {
1604: return $this->validationFailures;
1605: }
1606:
1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 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: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 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:
1652:
1653:
1654:
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: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 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: 1711: 1712: 1713: 1714: 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: }
1795: }
1796:
1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 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: 1862: 1863: 1864: 1865: 1866: 1867: 1868: 1869: 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: 1880: 1881: 1882: 1883: 1884: 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: }
1962: }
1963:
1964: 1965: 1966: 1967: 1968: 1969: 1970: 1971: 1972: 1973: 1974: 1975: 1976: 1977: 1978: 1979: 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: 2013: 2014: 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: 2050: 2051: 2052: 2053: 2054: 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: 2066: 2067:
2068: public function getPrimaryKey()
2069: {
2070: return $this->getId();
2071: }
2072:
2073: 2074: 2075: 2076: 2077: 2078:
2079: public function setPrimaryKey($key)
2080: {
2081: $this->setId($key);
2082: }
2083:
2084: 2085: 2086: 2087:
2088: public function isPrimaryKeyNull()
2089: {
2090:
2091: return null === $this->getId();
2092: }
2093:
2094: 2095: 2096: 2097: 2098: 2099: 2100: 2101: 2102: 2103: 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:
2133:
2134: $copyObj->setNew(false);
2135:
2136: $this->startCopy = true;
2137:
2138: foreach ($this->getAddresss() as $relObj) {
2139: if ($relObj !== $this) {
2140: $copyObj->addAddress($relObj->copy($deepCopy));
2141: }
2142: }
2143:
2144: foreach ($this->getOrders() as $relObj) {
2145: if ($relObj !== $this) {
2146: $copyObj->addOrder($relObj->copy($deepCopy));
2147: }
2148: }
2149:
2150:
2151: $this->startCopy = false;
2152: }
2153:
2154: if ($makeNew) {
2155: $copyObj->setNew(true);
2156: $copyObj->setId(NULL);
2157: }
2158: }
2159:
2160: 2161: 2162: 2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170: 2171:
2172: public function copy($deepCopy = false)
2173: {
2174:
2175: $clazz = get_class($this);
2176: $copyObj = new $clazz();
2177: $this->copyInto($copyObj, $deepCopy);
2178:
2179: return $copyObj;
2180: }
2181:
2182: 2183: 2184: 2185: 2186: 2187: 2188: 2189: 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: 2202: 2203: 2204: 2205: 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:
2218:
2219: if ($v !== null) {
2220: $v->addCustomer($this);
2221: }
2222:
2223:
2224: return $this;
2225: }
2226:
2227:
2228: 2229: 2230: 2231: 2232: 2233: 2234: 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: 2241: 2242: 2243: 2244: 2245: 2246:
2247: }
2248:
2249: return $this->aCustomerTitle;
2250: }
2251:
2252:
2253: 2254: 2255: 2256: 2257: 2258: 2259: 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: 2273: 2274: 2275: 2276: 2277: 2278: 2279:
2280: public function clearAddresss()
2281: {
2282: $this->collAddresss = null;
2283: $this->collAddresssPartial = null;
2284:
2285: return $this;
2286: }
2287:
2288: 2289: 2290: 2291: 2292:
2293: public function resetPartialAddresss($v = true)
2294: {
2295: $this->collAddresssPartial = $v;
2296: }
2297:
2298: 2299: 2300: 2301: 2302: 2303: 2304: 2305: 2306: 2307: 2308: 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: 2321: 2322: 2323: 2324: 2325: 2326: 2327: 2328: 2329: 2330: 2331: 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:
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: 2379: 2380: 2381: 2382: 2383: 2384: 2385: 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: 2410: 2411: 2412: 2413: 2414: 2415: 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: 2443: 2444: 2445: 2446: 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)) {
2455: $this->doAddAddress($l);
2456: }
2457:
2458: return $this;
2459: }
2460:
2461: 2462: 2463:
2464: protected function doAddAddress($address)
2465: {
2466: $this->collAddresss[]= $address;
2467: $address->setCustomer($this);
2468: }
2469:
2470: 2471: 2472: 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: 2492: 2493: 2494: 2495: 2496: 2497: 2498: 2499: 2500: 2501: 2502: 2503: 2504: 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: 2516: 2517: 2518: 2519: 2520: 2521: 2522:
2523: public function clearOrders()
2524: {
2525: $this->collOrders = null;
2526: $this->collOrdersPartial = null;
2527:
2528: return $this;
2529: }
2530:
2531: 2532: 2533: 2534: 2535:
2536: public function resetPartialOrders($v = true)
2537: {
2538: $this->collOrdersPartial = $v;
2539: }
2540:
2541: 2542: 2543: 2544: 2545: 2546: 2547: 2548: 2549: 2550: 2551: 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: 2564: 2565: 2566: 2567: 2568: 2569: 2570: 2571: 2572: 2573: 2574: 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:
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: 2622: 2623: 2624: 2625: 2626: 2627: 2628: 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: 2653: 2654: 2655: 2656: 2657: 2658: 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: 2686: 2687: 2688: 2689: 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)) {
2698: $this->doAddOrder($l);
2699: }
2700:
2701: return $this;
2702: }
2703:
2704: 2705: 2706:
2707: protected function doAddOrder($order)
2708: {
2709: $this->collOrders[]= $order;
2710: $order->setCustomer($this);
2711: }
2712:
2713: 2714: 2715: 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: 2735: 2736: 2737: 2738: 2739: 2740: 2741: 2742: 2743: 2744: 2745: 2746: 2747: 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: 2760: 2761: 2762: 2763: 2764: 2765: 2766: 2767: 2768: 2769: 2770: 2771: 2772: 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: 2785: 2786: 2787: 2788: 2789: 2790: 2791: 2792: 2793: 2794: 2795: 2796: 2797: 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: 2810: 2811: 2812: 2813: 2814: 2815: 2816: 2817: 2818: 2819: 2820: 2821: 2822: 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: 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: 2872: 2873: 2874: 2875: 2876: 2877: 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: }
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: 2913: 2914: 2915:
2916: public function __toString()
2917: {
2918: return (string) $this->exportTo(CustomerPeer::DEFAULT_STRING_FORMAT);
2919: }
2920:
2921: 2922: 2923: 2924: 2925:
2926: public function isAlreadyInSave()
2927: {
2928: return $this->alreadyInSave;
2929: }
2930:
2931:
2932:
2933: 2934: 2935: 2936: 2937:
2938: public function keepUpdateDateUnchanged()
2939: {
2940: $this->modifiedColumns[] = CustomerPeer::UPDATED_AT;
2941:
2942: return $this;
2943: }
2944:
2945: }
2946: