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($and_clear_all_references = false)
473: {
474: if ($and_clear_all_references)
475: {
476: foreach (CustomerPeer::$instances as $instance)
477: {
478: $instance->clearAllReferences(true);
479: }
480: }
481: CustomerPeer::$instances = array();
482: }
483:
484: 485: 486: 487:
488: public static function clearRelatedInstancePool()
489: {
490:
491:
492: AddressPeer::clearInstancePool();
493:
494:
495: OrderPeer::clearInstancePool();
496: }
497:
498: 499: 500: 501: 502: 503: 504: 505: 506: 507:
508: public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
509: {
510:
511: if ($row[$startcol] === null) {
512: return null;
513: }
514:
515: return (string) $row[$startcol];
516: }
517:
518: 519: 520: 521: 522: 523: 524: 525: 526:
527: public static function getPrimaryKeyFromRow($row, $startcol = 0)
528: {
529:
530: return (int) $row[$startcol];
531: }
532:
533: 534: 535: 536: 537: 538: 539:
540: public static function populateObjects(PDOStatement $stmt)
541: {
542: $results = array();
543:
544:
545: $cls = CustomerPeer::getOMClass();
546:
547: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
548: $key = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
549: if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
550:
551:
552:
553: $results[] = $obj;
554: } else {
555: $obj = new $cls();
556: $obj->hydrate($row);
557: $results[] = $obj;
558: CustomerPeer::addInstanceToPool($obj, $key);
559: }
560: }
561: $stmt->closeCursor();
562:
563: return $results;
564: }
565: 566: 567: 568: 569: 570: 571: 572: 573:
574: public static function populateObject($row, $startcol = 0)
575: {
576: $key = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
577: if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) {
578:
579:
580:
581: $col = $startcol + CustomerPeer::NUM_HYDRATE_COLUMNS;
582: } else {
583: $cls = CustomerPeer::OM_CLASS;
584: $obj = new $cls();
585: $col = $obj->hydrate($row, $startcol);
586: CustomerPeer::addInstanceToPool($obj, $key);
587: }
588:
589: return array($obj, $col);
590: }
591:
592:
593: 594: 595: 596: 597: 598: 599: 600: 601:
602: public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
603: {
604:
605: $criteria = clone $criteria;
606:
607:
608:
609:
610: $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
611:
612: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
613: $criteria->setDistinct();
614: }
615:
616: if (!$criteria->hasSelectClause()) {
617: CustomerPeer::addSelectColumns($criteria);
618: }
619:
620: $criteria->clearOrderByColumns();
621:
622:
623: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
624:
625: if ($con === null) {
626: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
627: }
628:
629: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
630:
631: $stmt = BasePeer::doCount($criteria, $con);
632:
633: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
634: $count = (int) $row[0];
635: } else {
636: $count = 0;
637: }
638: $stmt->closeCursor();
639:
640: return $count;
641: }
642:
643:
644: 645: 646: 647: 648: 649: 650: 651: 652:
653: public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
654: {
655: $criteria = clone $criteria;
656:
657:
658: if ($criteria->getDbName() == Propel::getDefaultDB()) {
659: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
660: }
661:
662: CustomerPeer::addSelectColumns($criteria);
663: $startcol = CustomerPeer::NUM_HYDRATE_COLUMNS;
664: CustomerTitlePeer::addSelectColumns($criteria);
665:
666: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
667:
668: $stmt = BasePeer::doSelect($criteria, $con);
669: $results = array();
670:
671: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
672: $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
673: if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
674:
675:
676:
677: } else {
678:
679: $cls = CustomerPeer::getOMClass();
680:
681: $obj1 = new $cls();
682: $obj1->hydrate($row);
683: CustomerPeer::addInstanceToPool($obj1, $key1);
684: }
685:
686: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
687: if ($key2 !== null) {
688: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
689: if (!$obj2) {
690:
691: $cls = CustomerTitlePeer::getOMClass();
692:
693: $obj2 = new $cls();
694: $obj2->hydrate($row, $startcol);
695: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
696: }
697:
698:
699: $obj2->addCustomer($obj1);
700:
701: }
702:
703: $results[] = $obj1;
704: }
705: $stmt->closeCursor();
706:
707: return $results;
708: }
709:
710:
711: 712: 713: 714: 715: 716: 717: 718: 719:
720: public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
721: {
722:
723: $criteria = clone $criteria;
724:
725:
726:
727:
728: $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
729:
730: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
731: $criteria->setDistinct();
732: }
733:
734: if (!$criteria->hasSelectClause()) {
735: CustomerPeer::addSelectColumns($criteria);
736: }
737:
738: $criteria->clearOrderByColumns();
739:
740:
741: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
742:
743: if ($con === null) {
744: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
745: }
746:
747: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
748:
749: $stmt = BasePeer::doCount($criteria, $con);
750:
751: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
752: $count = (int) $row[0];
753: } else {
754: $count = 0;
755: }
756: $stmt->closeCursor();
757:
758: return $count;
759: }
760:
761: 762: 763: 764: 765: 766: 767: 768: 769: 770:
771: public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
772: {
773: $criteria = clone $criteria;
774:
775:
776: if ($criteria->getDbName() == Propel::getDefaultDB()) {
777: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
778: }
779:
780: CustomerPeer::addSelectColumns($criteria);
781: $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS;
782:
783: CustomerTitlePeer::addSelectColumns($criteria);
784: $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
785:
786: $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior);
787:
788: $stmt = BasePeer::doSelect($criteria, $con);
789: $results = array();
790:
791: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
792: $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0);
793: if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) {
794:
795:
796:
797: } else {
798: $cls = CustomerPeer::getOMClass();
799:
800: $obj1 = new $cls();
801: $obj1->hydrate($row);
802: CustomerPeer::addInstanceToPool($obj1, $key1);
803: }
804:
805:
806:
807: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
808: if ($key2 !== null) {
809: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
810: if (!$obj2) {
811:
812: $cls = CustomerTitlePeer::getOMClass();
813:
814: $obj2 = new $cls();
815: $obj2->hydrate($row, $startcol2);
816: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
817: }
818:
819:
820: $obj2->addCustomer($obj1);
821: }
822:
823: $results[] = $obj1;
824: }
825: $stmt->closeCursor();
826:
827: return $results;
828: }
829:
830: 831: 832: 833: 834: 835: 836:
837: public static function getTableMap()
838: {
839: return Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME)->getTable(CustomerPeer::TABLE_NAME);
840: }
841:
842: 843: 844:
845: public static function buildTableMap()
846: {
847: $dbMap = Propel::getDatabaseMap(BaseCustomerPeer::DATABASE_NAME);
848: if (!$dbMap->hasTable(BaseCustomerPeer::TABLE_NAME)) {
849: $dbMap->addTableObject(new CustomerTableMap());
850: }
851: }
852:
853: 854: 855: 856: 857: 858:
859: public static function getOMClass($row = 0, $colnum = 0)
860: {
861: return CustomerPeer::OM_CLASS;
862: }
863:
864: 865: 866: 867: 868: 869: 870: 871: 872:
873: public static function doInsert($values, PropelPDO $con = null)
874: {
875: if ($con === null) {
876: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
877: }
878:
879: if ($values instanceof Criteria) {
880: $criteria = clone $values;
881: } else {
882: $criteria = $values->buildCriteria();
883: }
884:
885: if ($criteria->containsKey(CustomerPeer::ID) && $criteria->keyContainsValue(CustomerPeer::ID) ) {
886: throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerPeer::ID.')');
887: }
888:
889:
890:
891: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
892:
893: try {
894:
895:
896: $con->beginTransaction();
897: $pk = BasePeer::doInsert($criteria, $con);
898: $con->commit();
899: } catch (PropelException $e) {
900: $con->rollBack();
901: throw $e;
902: }
903:
904: return $pk;
905: }
906:
907: 908: 909: 910: 911: 912: 913: 914: 915:
916: public static function doUpdate($values, PropelPDO $con = null)
917: {
918: if ($con === null) {
919: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
920: }
921:
922: $selectCriteria = new Criteria(CustomerPeer::DATABASE_NAME);
923:
924: if ($values instanceof Criteria) {
925: $criteria = clone $values;
926:
927: $comparison = $criteria->getComparison(CustomerPeer::ID);
928: $value = $criteria->remove(CustomerPeer::ID);
929: if ($value) {
930: $selectCriteria->add(CustomerPeer::ID, $value, $comparison);
931: } else {
932: $selectCriteria->setPrimaryTableName(CustomerPeer::TABLE_NAME);
933: }
934:
935: } else {
936: $criteria = $values->buildCriteria();
937: $selectCriteria = $values->buildPkeyCriteria();
938: }
939:
940:
941: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
942:
943: return BasePeer::doUpdate($selectCriteria, $criteria, $con);
944: }
945:
946: 947: 948: 949: 950: 951: 952:
953: public static function doDeleteAll(PropelPDO $con = null)
954: {
955: if ($con === null) {
956: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
957: }
958: $affectedRows = 0;
959: try {
960:
961:
962: $con->beginTransaction();
963: $affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME);
964:
965:
966:
967: CustomerPeer::clearInstancePool();
968: CustomerPeer::clearRelatedInstancePool();
969: $con->commit();
970:
971: return $affectedRows;
972: } catch (PropelException $e) {
973: $con->rollBack();
974: throw $e;
975: }
976: }
977:
978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988:
989: public static function doDelete($values, PropelPDO $con = null)
990: {
991: if ($con === null) {
992: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
993: }
994:
995: if ($values instanceof Criteria) {
996:
997:
998:
999: CustomerPeer::clearInstancePool();
1000:
1001: $criteria = clone $values;
1002: } elseif ($values instanceof Customer) {
1003:
1004: CustomerPeer::removeInstanceFromPool($values);
1005:
1006: $criteria = $values->buildPkeyCriteria();
1007: } else {
1008: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1009: $criteria->add(CustomerPeer::ID, (array) $values, Criteria::IN);
1010:
1011: foreach ((array) $values as $singleval) {
1012: CustomerPeer::removeInstanceFromPool($singleval);
1013: }
1014: }
1015:
1016:
1017: $criteria->setDbName(CustomerPeer::DATABASE_NAME);
1018:
1019: $affectedRows = 0;
1020:
1021: try {
1022:
1023:
1024: $con->beginTransaction();
1025:
1026: $affectedRows += BasePeer::doDelete($criteria, $con);
1027: CustomerPeer::clearRelatedInstancePool();
1028: $con->commit();
1029:
1030: return $affectedRows;
1031: } catch (PropelException $e) {
1032: $con->rollBack();
1033: throw $e;
1034: }
1035: }
1036:
1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048:
1049: public static function doValidate($obj, $cols = null)
1050: {
1051: $columns = array();
1052:
1053: if ($cols) {
1054: $dbMap = Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME);
1055: $tableMap = $dbMap->getTable(CustomerPeer::TABLE_NAME);
1056:
1057: if (! is_array($cols)) {
1058: $cols = array($cols);
1059: }
1060:
1061: foreach ($cols as $colName) {
1062: if ($tableMap->hasColumn($colName)) {
1063: $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
1064: $columns[$colName] = $obj->$get();
1065: }
1066: }
1067: } else {
1068:
1069: }
1070:
1071: return BasePeer::doValidate(CustomerPeer::DATABASE_NAME, CustomerPeer::TABLE_NAME, $columns);
1072: }
1073:
1074: 1075: 1076: 1077: 1078: 1079: 1080:
1081: public static function retrieveByPK($pk, PropelPDO $con = null)
1082: {
1083:
1084: if (null !== ($obj = CustomerPeer::getInstanceFromPool((string) $pk))) {
1085: return $obj;
1086: }
1087:
1088: if ($con === null) {
1089: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1090: }
1091:
1092: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1093: $criteria->add(CustomerPeer::ID, $pk);
1094:
1095: $v = CustomerPeer::doSelect($criteria, $con);
1096:
1097: return !empty($v) > 0 ? $v[0] : null;
1098: }
1099:
1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108:
1109: public static function retrieveByPKs($pks, PropelPDO $con = null)
1110: {
1111: if ($con === null) {
1112: $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1113: }
1114:
1115: $objs = null;
1116: if (empty($pks)) {
1117: $objs = array();
1118: } else {
1119: $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
1120: $criteria->add(CustomerPeer::ID, $pks, Criteria::IN);
1121: $objs = CustomerPeer::doSelect($criteria, $con);
1122: }
1123:
1124: return $objs;
1125: }
1126:
1127: }
1128:
1129:
1130:
1131: BaseCustomerPeer::buildTableMap();
1132:
1133: