1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \BasePeer;
6: use \Criteria;
7: use \PDO;
8: use \PDOStatement;
9: use \Propel;
10: use \PropelException;
11: use \PropelPDO;
12: use Thelia\Model\AddressPeer;
13: use Thelia\Model\Customer;
14: use Thelia\Model\CustomerPeer;
15: use Thelia\Model\CustomerTitlePeer;
16: use Thelia\Model\OrderPeer;
17: use Thelia\Model\map\CustomerTableMap;
18:
19: 20: 21: 22: 23: 24: 25:
26: abstract class BaseCustomerPeer
27: {
28:
29:
30: const DATABASE_NAME = 'thelia';
31:
32:
33: const TABLE_NAME = 'customer';
34:
35:
36: const OM_CLASS = 'Thelia\\Model\\Customer';
37:
38:
39: const TM_CLASS = 'CustomerTableMap';
40:
41:
42: const NUM_COLUMNS = 24;
43:
44:
45: const NUM_LAZY_LOAD_COLUMNS = 0;
46:
47:
48: const NUM_HYDRATE_COLUMNS = 24;
49:
50:
51: const ID = 'customer.ID';
52:
53:
54: const REF = 'customer.REF';
55:
56:
57: const CUSTOMER_TITLE_ID = 'customer.CUSTOMER_TITLE_ID';
58:
59:
60: const COMPANY = 'customer.COMPANY';
61:
62:
63: const FIRSTNAME = 'customer.FIRSTNAME';
64:
65:
66: const LASTNAME = 'customer.LASTNAME';
67:
68:
69: const ADDRESS1 = 'customer.ADDRESS1';
70:
71:
72: const ADDRESS2 = 'customer.ADDRESS2';
73:
74:
75: const ADDRESS3 = 'customer.ADDRESS3';
76:
77:
78: const ZIPCODE = 'customer.ZIPCODE';
79:
80:
81: const CITY = 'customer.CITY';
82:
83:
84: const COUNTRY_ID = 'customer.COUNTRY_ID';
85:
86:
87: const PHONE = 'customer.PHONE';
88:
89:
90: const CELLPHONE = 'customer.CELLPHONE';
91:
92:
93: const EMAIL = 'customer.EMAIL';
94:
95:
96: const PASSWORD = 'customer.PASSWORD';
97:
98:
99: const ALGO = 'customer.ALGO';
100:
101:
102: const SALT = 'customer.SALT';
103:
104:
105: const RESELLER = 'customer.RESELLER';
106:
107:
108: const LANG = 'customer.LANG';
109:
110:
111: const = 'customer.SPONSOR';
112:
113:
114: const DISCOUNT = 'customer.DISCOUNT';
115:
116:
117: const CREATED_AT = 'customer.CREATED_AT';
118:
119:
120: const UPDATED_AT = 'customer.UPDATED_AT';
121:
122:
123: const DEFAULT_STRING_FORMAT = 'YAML';
124:
125: 126: 127: 128: 129: 130:
131: public static $instances = array();
132:
133:
134: 135: 136: 137: 138: 139:
140: protected static $fieldNames = array (
141: BasePeer::TYPE_PHPNAME => array ('Id', 'Ref', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Email', 'Password', 'Algo', 'Salt', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ),
142: BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ),
143: BasePeer::TYPE_COLNAME => array (CustomerPeer::ID, CustomerPeer::REF, CustomerPeer::CUSTOMER_TITLE_ID, CustomerPeer::COMPANY, CustomerPeer::FIRSTNAME, CustomerPeer::LASTNAME, CustomerPeer::ADDRESS1, CustomerPeer::ADDRESS2, CustomerPeer::ADDRESS3, CustomerPeer::ZIPCODE, CustomerPeer::CITY, CustomerPeer::COUNTRY_ID, CustomerPeer::PHONE, CustomerPeer::CELLPHONE, CustomerPeer::EMAIL, CustomerPeer::PASSWORD, CustomerPeer::ALGO, CustomerPeer::SALT, CustomerPeer::RESELLER, CustomerPeer::LANG, CustomerPeer::SPONSOR, CustomerPeer::DISCOUNT, CustomerPeer::CREATED_AT, CustomerPeer::UPDATED_AT, ),
144: BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'EMAIL', 'PASSWORD', 'ALGO', 'SALT', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
145: BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ),
146: BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, )
147: );
148:
149: 150: 151: 152: 153: 154:
155: protected static $fieldKeys = array (
156: BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerTitleId' => 2, 'Company' => 3, 'Firstname' => 4, 'Lastname' => 5, 'Address1' => 6, 'Address2' => 7, 'Address3' => 8, 'Zipcode' => 9, 'City' => 10, 'CountryId' => 11, 'Phone' => 12, 'Cellphone' => 13, 'Email' => 14, 'Password' => 15, 'Algo' => 16, 'Salt' => 17, 'Reseller' => 18, 'Lang' => 19, 'Sponsor' => 20, 'Discount' => 21, 'CreatedAt' => 22, 'UpdatedAt' => 23, ),
157: BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerTitleId' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'countryId' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'createdAt' => 22, 'updatedAt' => 23, ),
158: BasePeer::TYPE_COLNAME => array (CustomerPeer::ID => 0, CustomerPeer::REF => 1, CustomerPeer::CUSTOMER_TITLE_ID => 2, CustomerPeer::COMPANY => 3, CustomerPeer::FIRSTNAME => 4, CustomerPeer::LASTNAME => 5, CustomerPeer::ADDRESS1 => 6, CustomerPeer::ADDRESS2 => 7, CustomerPeer::ADDRESS3 => 8, CustomerPeer::ZIPCODE => 9, CustomerPeer::CITY => 10, CustomerPeer::COUNTRY_ID => 11, CustomerPeer::PHONE => 12, CustomerPeer::CELLPHONE => 13, CustomerPeer::EMAIL => 14, CustomerPeer::PASSWORD => 15, CustomerPeer::ALGO => 16, CustomerPeer::SALT => 17, CustomerPeer::RESELLER => 18, CustomerPeer::LANG => 19, CustomerPeer::SPONSOR => 20, CustomerPeer::DISCOUNT => 21, CustomerPeer::CREATED_AT => 22, CustomerPeer::UPDATED_AT => 23, ),
159: BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_TITLE_ID' => 2, 'COMPANY' => 3, 'FIRSTNAME' => 4, 'LASTNAME' => 5, 'ADDRESS1' => 6, 'ADDRESS2' => 7, 'ADDRESS3' => 8, 'ZIPCODE' => 9, 'CITY' => 10, 'COUNTRY_ID' => 11, 'PHONE' => 12, 'CELLPHONE' => 13, 'EMAIL' => 14, 'PASSWORD' => 15, 'ALGO' => 16, 'SALT' => 17, 'RESELLER' => 18, 'LANG' => 19, 'SPONSOR' => 20, 'DISCOUNT' => 21, 'CREATED_AT' => 22, 'UPDATED_AT' => 23, ),
160: BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_title_id' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'country_id' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'created_at' => 22, 'updated_at' => 23, ),
161: BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, )
162: );
163:
164: 165: 166: 167: 168: 169: 170: 171: 172: 173:
174: public static function translateFieldName($name, $fromType, $toType)
175: {
176: $toNames = CustomerPeer::getFieldNames($toType);
177: $key = isset(CustomerPeer::$fieldKeys[$fromType][$name]) ? CustomerPeer::$fieldKeys[$fromType][$name] : null;
178: if ($key === null) {
179: throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerPeer::$fieldKeys[$fromType], true));
180: }
181:
182: return $toNames[$key];
183: }
184:
185: 186: 187: 188: 189: 190: 191: 192: 193:
194: public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
195: {
196: if (!array_key_exists($type, CustomerPeer::$fieldNames)) {
197: throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
198: }
199:
200: return CustomerPeer::$fieldNames[$type];
201: }
202:
203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214:
215: public static function alias($alias, $column)
216: {
217: return str_replace(CustomerPeer::TABLE_NAME.'.', $alias.'.', $column);
218: }
219:
220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231:
232: public static function addSelectColumns(Criteria $criteria, $alias = null)
233: {
234: if (null === $alias) {
235: $criteria->addSelectColumn(CustomerPeer::ID);
236: $criteria->addSelectColumn(CustomerPeer::REF);
237: $criteria->addSelectColumn(CustomerPeer::CUSTOMER_TITLE_ID);
238: $criteria->addSelectColumn(CustomerPeer::COMPANY);
239: $criteria->addSelectColumn(CustomerPeer::FIRSTNAME);
240: $criteria->addSelectColumn(CustomerPeer::LASTNAME);
241: $criteria->addSelectColumn(CustomerPeer::ADDRESS1);
242: $criteria->addSelectColumn(CustomerPeer::ADDRESS2);
243: $criteria->addSelectColumn(CustomerPeer::ADDRESS3);
244: $criteria->addSelectColumn(CustomerPeer::ZIPCODE);
245: $criteria->addSelectColumn(CustomerPeer::CITY);
246: $criteria->addSelectColumn(CustomerPeer::COUNTRY_ID);
247: $criteria->addSelectColumn(CustomerPeer::PHONE);
248: $criteria->addSelectColumn(CustomerPeer::CELLPHONE);
249: $criteria->addSelectColumn(CustomerPeer::EMAIL);
250: $criteria->addSelectColumn(CustomerPeer::PASSWORD);
251: $criteria->addSelectColumn(CustomerPeer::ALGO);
252: $criteria->addSelectColumn(CustomerPeer::SALT);
253: $criteria->addSelectColumn(CustomerPeer::RESELLER);
254: $criteria->addSelectColumn(CustomerPeer::LANG);
255: $criteria->addSelectColumn(CustomerPeer::SPONSOR);
256: $criteria->addSelectColumn(CustomerPeer::DISCOUNT);
257: $criteria->addSelectColumn(CustomerPeer::CREATED_AT);
258: $criteria->addSelectColumn(CustomerPeer::UPDATED_AT);
259: } else {
260: $criteria->addSelectColumn($alias . '.ID');
261: $criteria->addSelectColumn($alias . '.REF');
262: $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
263: $criteria->addSelectColumn($alias . '.COMPANY');
264: $criteria->addSelectColumn($alias . '.FIRSTNAME');
265: $criteria->addSelectColumn($alias . '.LASTNAME');
266: $criteria->addSelectColumn($alias . '.ADDRESS1');
267: $criteria->addSelectColumn($alias . '.ADDRESS2');
268: $criteria->addSelectColumn($alias . '.ADDRESS3');
269: $criteria->addSelectColumn($alias . '.ZIPCODE');
270: $criteria->addSelectColumn($alias . '.CITY');
271: $criteria->addSelectColumn($alias . '.COUNTRY_ID');
272: $criteria->addSelectColumn($alias . '.PHONE');
273: $criteria->addSelectColumn($alias . '.CELLPHONE');
274: $criteria->addSelectColumn($alias . '.EMAIL');
275: $criteria->addSelectColumn($alias . '.PASSWORD');
276: $criteria->addSelectColumn($alias . '.ALGO');
277: $criteria->addSelectColumn($alias . '.SALT');
278: $criteria->addSelectColumn($alias . '.RESELLER');
279: $criteria->addSelectColumn($alias . '.LANG');
280: $criteria->addSelectColumn($alias . '.SPONSOR');
281: $criteria->addSelectColumn($alias . '.DISCOUNT');
282: $criteria->addSelectColumn($alias . '.CREATED_AT');
283: $criteria->addSelectColumn($alias . '.UPDATED_AT');
284: }
285: }
286:
287: 288: 289: 290: 291: 292: 293: 294:
295: public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
296: {
297:
298: $criteria = clone $criteria;
299:
300:
301:
302:
303: $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
304:
305: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
306: $criteria->setDistinct();
307: }
308:
309: if (!$criteria->hasSelectClause()) {
310: CustomerPeer::addSelectColumns($criteria);
311: }
312:
313: $criteria->clearOrderByColumns();
314: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
315:
316: if ($con === null) {
317: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
318: }
319:
320: $stmt = BasePeer::doCount($criteria, $con);
321:
322: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
323: $count = (int) $row[0];
324: } else {
325: $count = 0;
326: }
327: $stmt->closeCursor();
328:
329: return $count;
330: }
331: 332: 333: 334: 335: 336: 337: 338: 339:
340: public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
341: {
342: $critcopy = clone $criteria;
343: $critcopy->setLimit(1);
344: $objects = CustomerPeer::doSelect($critcopy, $con);
345: if ($objects) {
346: return $objects[0];
347: }
348:
349: return null;
350: }
351: 352: 353: 354: 355: 356: 357: 358: 359:
360: public static function doSelect(Criteria $criteria, PropelPDO $con = null)
361: {
362: return CustomerPeer::populateObjects(CustomerPeer::doSelectStmt($criteria, $con));
363: }
364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376:
377: public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
378: {
379: if ($con === null) {
380: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
381: }
382:
383: if (!$criteria->hasSelectClause()) {
384: $criteria = clone $criteria;
385: CustomerPeer::addSelectColumns($criteria);
386: }
387:
388:
389: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
390:
391:
392: return BasePeer::doSelect($criteria, $con);
393: }
394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405:
406: public static function addInstanceToPool($obj, $key = null)
407: {
408: if (Propel::isInstancePoolingEnabled()) {
409: if ($key === null) {
410: $key = (string) $obj->getId();
411: }
412: CustomerPeer::$instances[$key] = $obj;
413: }
414: }
415:
416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428:
429: public static function removeInstanceFromPool($value)
430: {
431: if (Propel::isInstancePoolingEnabled() && $value !== null) {
432: if (is_object($value) && $value instanceof Customer) {
433: $key = (string) $value->getId();
434: } elseif (is_scalar($value)) {
435:
436: $key = (string) $value;
437: } else {
438: $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Customer object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
439: throw $e;
440: }
441:
442: unset(CustomerPeer::$instances[$key]);
443: }
444: }
445:
446: 447: 448: 449: 450: 451: 452: 453: 454: 455:
456: public static function getInstanceFromPool($key)
457: {
458: if (Propel::isInstancePoolingEnabled()) {
459: if (isset(CustomerPeer::$instances[$key])) {
460: return CustomerPeer::$instances[$key];
461: }
462: }
463:
464: return null;
465: }
466:
467: 468: 469: 470: 471:
472: public static function clearInstancePool()
473: {
474: CustomerPeer::$instances = array();
475: }
476:
477: 478: 479: 480:
481: public static function clearRelatedInstancePool()
482: {
483:
484:
485: AddressPeer::clearInstancePool();
486:
487:
488: OrderPeer::clearInstancePool();
489: }
490:
491: 492: 493: 494: 495: 496: 497: 498: 499: 500:
501: public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
502: {
503:
504: if ($row[$startcol] === null) {
505: return null;
506: }
507:
508: return (string) $row[$startcol];
509: }
510:
511: 512: 513: 514: 515: 516: 517: 518: 519:
520: public static function getPrimaryKeyFromRow($row, $startcol = 0)
521: {
522:
523: return (int) $row[$startcol];
524: }
525:
526: 527: 528: 529: 530: 531: 532:
533: public static function populateObjects(PDOStatement $stmt)
534: {
535: $results = array();
536:
537:
538: $cls = CustomerPeer::getOMClass();
539:
540: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
541: $key = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
542: if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
543:
544:
545:
546: $results[] = $obj;
547: } else {
548: $obj = new $cls();
549: $obj->hydrate($row);
550: $results[] = $obj;
551: CustomerPeer::addInstanceToPool($obj, $key);
552: }
553: }
554: $stmt->closeCursor();
555:
556: return $results;
557: }
558: 559: 560: 561: 562: 563: 564: 565: 566:
567: public static function populateObject($row, $startcol = 0)
568: {
569: $key = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
570: if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
571:
572:
573:
574: $col = $startcol + CustomerPeer::NUM_HYDRATE_COLUMNS;
575: } else {
576: $cls = CustomerPeer::OM_CLASS;
577: $obj = new $cls();
578: $col = $obj->hydrate($row, $startcol);
579: CustomerPeer::addInstanceToPool($obj, $key);
580: }
581:
582: return array($obj, $col);
583: }
584:
585:
586: 587: 588: 589: 590: 591: 592: 593: 594:
595: public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
596: {
597:
598: $criteria = clone $criteria;
599:
600:
601:
602:
603: $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
604:
605: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
606: $criteria->setDistinct();
607: }
608:
609: if (!$criteria->hasSelectClause()) {
610: CustomerPeer::addSelectColumns($criteria);
611: }
612:
613: $criteria->clearOrderByColumns();
614:
615:
616: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
617:
618: if ($con === null) {
619: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
620: }
621:
622: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
623:
624: $stmt = BasePeer::doCount($criteria, $con);
625:
626: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
627: $count = (int) $row[0];
628: } else {
629: $count = 0;
630: }
631: $stmt->closeCursor();
632:
633: return $count;
634: }
635:
636:
637: 638: 639: 640: 641: 642: 643: 644: 645:
646: public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
647: {
648: $criteria = clone $criteria;
649:
650:
651: if ($criteria->getDbName() == Propel::getDefaultDB()) {
652: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
653: }
654:
655: CustomerPeer::addSelectColumns($criteria);
656: $startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
657: CustomerTitlePeer::addSelectColumns($criteria);
658:
659: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
660:
661: $stmt = BasePeer::doSelect($criteria, $con);
662: $results = array();
663:
664: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
665: $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
666: if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
667:
668:
669:
670: } else {
671:
672: $cls = CustomerPeer::getOMClass();
673:
674: $obj1 = new $cls();
675: $obj1->hydrate($row);
676: CustomerPeer::addInstanceToPool($obj1, $key1);
677: }
678:
679: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
680: if ($key2 !== null) {
681: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
682: if (!$obj2) {
683:
684: $cls = CustomerTitlePeer::getOMClass();
685:
686: $obj2 = new $cls();
687: $obj2->hydrate($row, $startcol);
688: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
689: }
690:
691:
692: $obj2->addCustomer($obj1);
693:
694: }
695:
696: $results[] = $obj1;
697: }
698: $stmt->closeCursor();
699:
700: return $results;
701: }
702:
703:
704: 705: 706: 707: 708: 709: 710: 711: 712:
713: public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
714: {
715:
716: $criteria = clone $criteria;
717:
718:
719:
720:
721: $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
722:
723: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
724: $criteria->setDistinct();
725: }
726:
727: if (!$criteria->hasSelectClause()) {
728: CustomerPeer::addSelectColumns($criteria);
729: }
730:
731: $criteria->clearOrderByColumns();
732:
733:
734: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
735:
736: if ($con === null) {
737: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
738: }
739:
740: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
741:
742: $stmt = BasePeer::doCount($criteria, $con);
743:
744: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
745: $count = (int) $row[0];
746: } else {
747: $count = 0;
748: }
749: $stmt->closeCursor();
750:
751: return $count;
752: }
753:
754: 755: 756: 757: 758: 759: 760: 761: 762: 763:
764: public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
765: {
766: $criteria = clone $criteria;
767:
768:
769: if ($criteria->getDbName() == Propel::getDefaultDB()) {
770: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
771: }
772:
773: CustomerPeer::addSelectColumns($criteria);
774: $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
775:
776: CustomerTitlePeer::addSelectColumns($criteria);
777: $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
778:
779: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
780:
781: $stmt = BasePeer::doSelect($criteria, $con);
782: $results = array();
783:
784: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
785: $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
786: if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
787:
788:
789:
790: } else {
791: $cls = CustomerPeer::getOMClass();
792:
793: $obj1 = new $cls();
794: $obj1->hydrate($row);
795: CustomerPeer::addInstanceToPool($obj1, $key1);
796: }
797:
798:
799:
800: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
801: if ($key2 !== null) {
802: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
803: if (!$obj2) {
804:
805: $cls = CustomerTitlePeer::getOMClass();
806:
807: $obj2 = new $cls();
808: $obj2->hydrate($row, $startcol2);
809: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
810: }
811:
812:
813: $obj2->addCustomer($obj1);
814: }
815:
816: $results[] = $obj1;
817: }
818: $stmt->closeCursor();
819:
820: return $results;
821: }
822:
823: 824: 825: 826: 827: 828: 829:
830: public static function getTableMap()
831: {
832: return Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME)->getTable(CustomerPeer::TABLE_NAME);
833: }
834:
835: 836: 837:
838: public static function buildTableMap()
839: {
840: $dbMap = Propel::getDatabaseMap(BaseCustomerPeer::DATABASE_NAME);
841: if (!$dbMap->hasTable(BaseCustomerPeer::TABLE_NAME)) {
842: $dbMap->addTableObject(new CustomerTableMap());
843: }
844: }
845:
846: 847: 848: 849: 850: 851:
852: public static function getOMClass()
853: {
854: return CustomerPeer::OM_CLASS;
855: }
856:
857: 858: 859: 860: 861: 862: 863: 864: 865:
866: public static function doInsert($values, PropelPDO $con = null)
867: {
868: if ($con === null) {
869: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
870: }
871:
872: if ($values instanceof Criteria) {
873: $criteria = clone $values;
874: } else {
875: $criteria = $values->buildCriteria();
876: }
877:
878: if ($criteria->containsKey(CustomerPeer::ID) && $criteria->keyContainsValue(CustomerPeer::ID) ) {
879: throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerPeer::ID.')');
880: }
881:
882:
883:
884: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
885:
886: try {
887:
888:
889: $con->beginTransaction();
890: $pk = BasePeer::doInsert($criteria, $con);
891: $con->commit();
892: } catch (PropelException $e) {
893: $con->rollBack();
894: throw $e;
895: }
896:
897: return $pk;
898: }
899:
900: 901: 902: 903: 904: 905: 906: 907: 908:
909: public static function doUpdate($values, PropelPDO $con = null)
910: {
911: if ($con === null) {
912: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
913: }
914:
915: $selectCriteria = new Criteria(CustomerPeer::DATABASE_NAME);
916:
917: if ($values instanceof Criteria) {
918: $criteria = clone $values;
919:
920: $comparison = $criteria->getComparison(CustomerPeer::ID);
921: $value = $criteria->remove(CustomerPeer::ID);
922: if ($value) {
923: $selectCriteria->add(CustomerPeer::ID, $value, $comparison);
924: } else {
925: $selectCriteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
926: }
927:
928: } else {
929: $criteria = $values->buildCriteria();
930: $selectCriteria = $values->buildPkeyCriteria();
931: }
932:
933:
934: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
935:
936: return BasePeer::doUpdate($selectCriteria, $criteria, $con);
937: }
938:
939: 940: 941: 942: 943: 944: 945:
946: public static function doDeleteAll(PropelPDO $con = null)
947: {
948: if ($con === null) {
949: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
950: }
951: $affectedRows = 0;
952: try {
953:
954:
955: $con->beginTransaction();
956: $affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME);
957:
958:
959:
960: CustomerPeer::clearInstancePool();
961: CustomerPeer::clearRelatedInstancePool();
962: $con->commit();
963:
964: return $affectedRows;
965: } catch (PropelException $e) {
966: $con->rollBack();
967: throw $e;
968: }
969: }
970:
971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981:
982: public static function doDelete($values, PropelPDO $con = null)
983: {
984: if ($con === null) {
985: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
986: }
987:
988: if ($values instanceof Criteria) {
989:
990:
991:
992: CustomerPeer::clearInstancePool();
993:
994: $criteria = clone $values;
995: } elseif ($values instanceof Customer) {
996:
997: CustomerPeer::removeInstanceFromPool($values);
998:
999: $criteria = $values->buildPkeyCriteria();
1000: } else {
1001: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1002: $criteria->add(CustomerPeer::ID, (array) $values, Criteria::IN);
1003:
1004: foreach ((array) $values as $singleval) {
1005: CustomerPeer::removeInstanceFromPool($singleval);
1006: }
1007: }
1008:
1009:
1010: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
1011:
1012: $affectedRows = 0;
1013:
1014: try {
1015:
1016:
1017: $con->beginTransaction();
1018:
1019: $affectedRows += BasePeer::doDelete($criteria, $con);
1020: CustomerPeer::clearRelatedInstancePool();
1021: $con->commit();
1022:
1023: return $affectedRows;
1024: } catch (PropelException $e) {
1025: $con->rollBack();
1026: throw $e;
1027: }
1028: }
1029:
1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041:
1042: public static function doValidate($obj, $cols = null)
1043: {
1044: $columns = array();
1045:
1046: if ($cols) {
1047: $dbMap = Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME);
1048: $tableMap = $dbMap->getTable(CustomerPeer::TABLE_NAME);
1049:
1050: if (! is_array($cols)) {
1051: $cols = array($cols);
1052: }
1053:
1054: foreach ($cols as $colName) {
1055: if ($tableMap->hasColumn($colName)) {
1056: $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
1057: $columns[$colName] = $obj->$get();
1058: }
1059: }
1060: } else {
1061:
1062: }
1063:
1064: return BasePeer::doValidate(CustomerPeer::DATABASE_NAME, CustomerPeer::TABLE_NAME, $columns);
1065: }
1066:
1067: 1068: 1069: 1070: 1071: 1072: 1073:
1074: public static function retrieveByPK($pk, PropelPDO $con = null)
1075: {
1076:
1077: if (null !== ($obj = CustomerPeer::getInstanceFromPool((string) $pk))) {
1078: return $obj;
1079: }
1080:
1081: if ($con === null) {
1082: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1083: }
1084:
1085: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1086: $criteria->add(CustomerPeer::ID, $pk);
1087:
1088: $v = CustomerPeer::doSelect($criteria, $con);
1089:
1090: return !empty($v) > 0 ? $v[0] : null;
1091: }
1092:
1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101:
1102: public static function retrieveByPKs($pks, PropelPDO $con = null)
1103: {
1104: if ($con === null) {
1105: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1106: }
1107:
1108: $objs = null;
1109: if (empty($pks)) {
1110: $objs = array();
1111: } else {
1112: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1113: $criteria->add(CustomerPeer::ID, $pks, Criteria::IN);
1114: $objs = CustomerPeer::doSelect($criteria, $con);
1115: }
1116:
1117: return $objs;
1118: }
1119:
1120: }
1121:
1122:
1123:
1124: BaseCustomerPeer::buildTableMap();
1125:
1126: