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\CustomerTitleI18n;
13: use Thelia\Model\CustomerTitleI18nPeer;
14: use Thelia\Model\CustomerTitlePeer;
15: use Thelia\Model\map\CustomerTitleI18nTableMap;
16:
17: /**
18: * Base static class for performing query and update operations on the 'customer_title_i18n' table.
19: *
20: *
21: *
22: * @package propel.generator.Thelia.Model.om
23: */
24: abstract class BaseCustomerTitleI18nPeer
25: {
26:
27: /** the default database name for this class */
28: const DATABASE_NAME = 'thelia';
29:
30: /** the table name for this class */
31: const TABLE_NAME = 'customer_title_i18n';
32:
33: /** the related Propel class for this table */
34: const OM_CLASS = 'Thelia\\Model\\CustomerTitleI18n';
35:
36: /** the related TableMap class for this table */
37: const TM_CLASS = 'CustomerTitleI18nTableMap';
38:
39: /** The total number of columns. */
40: const NUM_COLUMNS = 4;
41:
42: /** The number of lazy-loaded columns. */
43: const NUM_LAZY_LOAD_COLUMNS = 0;
44:
45: /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
46: const NUM_HYDRATE_COLUMNS = 4;
47:
48: /** the column name for the ID field */
49: const ID = 'customer_title_i18n.ID';
50:
51: /** the column name for the LOCALE field */
52: const LOCALE = 'customer_title_i18n.LOCALE';
53:
54: /** the column name for the SHORT field */
55: const SHORT = 'customer_title_i18n.SHORT';
56:
57: /** the column name for the LONG field */
58: const LONG = 'customer_title_i18n.LONG';
59:
60: /** The default string format for model objects of the related table **/
61: const DEFAULT_STRING_FORMAT = 'YAML';
62:
63: /**
64: * An identiy map to hold any loaded instances of CustomerTitleI18n objects.
65: * This must be public so that other peer classes can access this when hydrating from JOIN
66: * queries.
67: * @var array CustomerTitleI18n[]
68: */
69: public static $instances = array();
70:
71:
72: /**
73: * holds an array of fieldnames
74: *
75: * first dimension keys are the type constants
76: * e.g. CustomerTitleI18nPeer::$fieldNames[CustomerTitleI18nPeer::TYPE_PHPNAME][0] = 'Id'
77: */
78: protected static $fieldNames = array (
79: BasePeer::TYPE_PHPNAME => array ('Id', 'Locale', 'Short', 'Long', ),
80: BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'short', 'long', ),
81: BasePeer::TYPE_COLNAME => array (CustomerTitleI18nPeer::ID, CustomerTitleI18nPeer::LOCALE, CustomerTitleI18nPeer::SHORT, CustomerTitleI18nPeer::LONG, ),
82: BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'SHORT', 'LONG', ),
83: BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'short', 'long', ),
84: BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
85: );
86:
87: /**
88: * holds an array of keys for quick access to the fieldnames array
89: *
90: * first dimension keys are the type constants
91: * e.g. CustomerTitleI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
92: */
93: protected static $fieldKeys = array (
94: BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Short' => 2, 'Long' => 3, ),
95: BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ),
96: BasePeer::TYPE_COLNAME => array (CustomerTitleI18nPeer::ID => 0, CustomerTitleI18nPeer::LOCALE => 1, CustomerTitleI18nPeer::SHORT => 2, CustomerTitleI18nPeer::LONG => 3, ),
97: BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'SHORT' => 2, 'LONG' => 3, ),
98: BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ),
99: BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
100: );
101:
102: /**
103: * Translates a fieldname to another type
104: *
105: * @param string $name field name
106: * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
107: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
108: * @param string $toType One of the class type constants
109: * @return string translated name of the field.
110: * @throws PropelException - if the specified name could not be found in the fieldname mappings.
111: */
112: public static function translateFieldName($name, $fromType, $toType)
113: {
114: $toNames = CustomerTitleI18nPeer::getFieldNames($toType);
115: $key = isset(CustomerTitleI18nPeer::$fieldKeys[$fromType][$name]) ? CustomerTitleI18nPeer::$fieldKeys[$fromType][$name] : null;
116: if ($key === null) {
117: throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerTitleI18nPeer::$fieldKeys[$fromType], true));
118: }
119:
120: return $toNames[$key];
121: }
122:
123: /**
124: * Returns an array of field names.
125: *
126: * @param string $type The type of fieldnames to return:
127: * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
128: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
129: * @return array A list of field names
130: * @throws PropelException - if the type is not valid.
131: */
132: public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
133: {
134: if (!array_key_exists($type, CustomerTitleI18nPeer::$fieldNames)) {
135: 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.');
136: }
137:
138: return CustomerTitleI18nPeer::$fieldNames[$type];
139: }
140:
141: /**
142: * Convenience method which changes table.column to alias.column.
143: *
144: * Using this method you can maintain SQL abstraction while using column aliases.
145: * <code>
146: * $c->addAlias("alias1", TablePeer::TABLE_NAME);
147: * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
148: * </code>
149: * @param string $alias The alias for the current table.
150: * @param string $column The column name for current table. (i.e. CustomerTitleI18nPeer::COLUMN_NAME).
151: * @return string
152: */
153: public static function alias($alias, $column)
154: {
155: return str_replace(CustomerTitleI18nPeer::TABLE_NAME.'.', $alias.'.', $column);
156: }
157:
158: /**
159: * Add all the columns needed to create a new object.
160: *
161: * Note: any columns that were marked with lazyLoad="true" in the
162: * XML schema will not be added to the select list and only loaded
163: * on demand.
164: *
165: * @param Criteria $criteria object containing the columns to add.
166: * @param string $alias optional table alias
167: * @throws PropelException Any exceptions caught during processing will be
168: * rethrown wrapped into a PropelException.
169: */
170: public static function addSelectColumns(Criteria $criteria, $alias = null)
171: {
172: if (null === $alias) {
173: $criteria->addSelectColumn(CustomerTitleI18nPeer::ID);
174: $criteria->addSelectColumn(CustomerTitleI18nPeer::LOCALE);
175: $criteria->addSelectColumn(CustomerTitleI18nPeer::SHORT);
176: $criteria->addSelectColumn(CustomerTitleI18nPeer::LONG);
177: } else {
178: $criteria->addSelectColumn($alias . '.ID');
179: $criteria->addSelectColumn($alias . '.LOCALE');
180: $criteria->addSelectColumn($alias . '.SHORT');
181: $criteria->addSelectColumn($alias . '.LONG');
182: }
183: }
184:
185: /**
186: * Returns the number of rows matching criteria.
187: *
188: * @param Criteria $criteria
189: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
190: * @param PropelPDO $con
191: * @return int Number of matching rows.
192: */
193: public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
194: {
195: // we may modify criteria, so copy it first
196: $criteria = clone $criteria;
197:
198: // We need to set the primary table name, since in the case that there are no WHERE columns
199: // it will be impossible for the BasePeer::createSelectSql() method to determine which
200: // tables go into the FROM clause.
201: $criteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME);
202:
203: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
204: $criteria->setDistinct();
205: }
206:
207: if (!$criteria->hasSelectClause()) {
208: CustomerTitleI18nPeer::addSelectColumns($criteria);
209: }
210:
211: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
212: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); // Set the correct dbName
213:
214: if ($con === null) {
215: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
216: }
217: // BasePeer returns a PDOStatement
218: $stmt = BasePeer::doCount($criteria, $con);
219:
220: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
221: $count = (int) $row[0];
222: } else {
223: $count = 0; // no rows returned; we infer that means 0 matches.
224: }
225: $stmt->closeCursor();
226:
227: return $count;
228: }
229: /**
230: * Selects one object from the DB.
231: *
232: * @param Criteria $criteria object used to create the SELECT statement.
233: * @param PropelPDO $con
234: * @return CustomerTitleI18n
235: * @throws PropelException Any exceptions caught during processing will be
236: * rethrown wrapped into a PropelException.
237: */
238: public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
239: {
240: $critcopy = clone $criteria;
241: $critcopy->setLimit(1);
242: $objects = CustomerTitleI18nPeer::doSelect($critcopy, $con);
243: if ($objects) {
244: return $objects[0];
245: }
246:
247: return null;
248: }
249: /**
250: * Selects several row from the DB.
251: *
252: * @param Criteria $criteria The Criteria object used to build the SELECT statement.
253: * @param PropelPDO $con
254: * @return array Array of selected Objects
255: * @throws PropelException Any exceptions caught during processing will be
256: * rethrown wrapped into a PropelException.
257: */
258: public static function doSelect(Criteria $criteria, PropelPDO $con = null)
259: {
260: return CustomerTitleI18nPeer::populateObjects(CustomerTitleI18nPeer::doSelectStmt($criteria, $con));
261: }
262: /**
263: * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
264: *
265: * Use this method directly if you want to work with an executed statement durirectly (for example
266: * to perform your own object hydration).
267: *
268: * @param Criteria $criteria The Criteria object used to build the SELECT statement.
269: * @param PropelPDO $con The connection to use
270: * @throws PropelException Any exceptions caught during processing will be
271: * rethrown wrapped into a PropelException.
272: * @return PDOStatement The executed PDOStatement object.
273: * @see BasePeer::doSelect()
274: */
275: public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
276: {
277: if ($con === null) {
278: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
279: }
280:
281: if (!$criteria->hasSelectClause()) {
282: $criteria = clone $criteria;
283: CustomerTitleI18nPeer::addSelectColumns($criteria);
284: }
285:
286: // Set the correct dbName
287: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
288:
289: // BasePeer returns a PDOStatement
290: return BasePeer::doSelect($criteria, $con);
291: }
292: /**
293: * Adds an object to the instance pool.
294: *
295: * Propel keeps cached copies of objects in an instance pool when they are retrieved
296: * from the database. In some cases -- especially when you override doSelect*()
297: * methods in your stub classes -- you may need to explicitly add objects
298: * to the cache in order to ensure that the same objects are always returned by doSelect*()
299: * and retrieveByPK*() calls.
300: *
301: * @param CustomerTitleI18n $obj A CustomerTitleI18n object.
302: * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
303: */
304: public static function addInstanceToPool($obj, $key = null)
305: {
306: if (Propel::isInstancePoolingEnabled()) {
307: if ($key === null) {
308: $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
309: } // if key === null
310: CustomerTitleI18nPeer::$instances[$key] = $obj;
311: }
312: }
313:
314: /**
315: * Removes an object from the instance pool.
316: *
317: * Propel keeps cached copies of objects in an instance pool when they are retrieved
318: * from the database. In some cases -- especially when you override doDelete
319: * methods in your stub classes -- you may need to explicitly remove objects
320: * from the cache in order to prevent returning objects that no longer exist.
321: *
322: * @param mixed $value A CustomerTitleI18n object or a primary key value.
323: *
324: * @return void
325: * @throws PropelException - if the value is invalid.
326: */
327: public static function removeInstanceFromPool($value)
328: {
329: if (Propel::isInstancePoolingEnabled() && $value !== null) {
330: if (is_object($value) && $value instanceof CustomerTitleI18n) {
331: $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
332: } elseif (is_array($value) && count($value) === 2) {
333: // assume we've been passed a primary key
334: $key = serialize(array((string) $value[0], (string) $value[1]));
335: } else {
336: $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CustomerTitleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
337: throw $e;
338: }
339:
340: unset(CustomerTitleI18nPeer::$instances[$key]);
341: }
342: } // removeInstanceFromPool()
343:
344: /**
345: * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
346: *
347: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
348: * a multi-column primary key, a serialize()d version of the primary key will be returned.
349: *
350: * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
351: * @return CustomerTitleI18n Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
352: * @see getPrimaryKeyHash()
353: */
354: public static function getInstanceFromPool($key)
355: {
356: if (Propel::isInstancePoolingEnabled()) {
357: if (isset(CustomerTitleI18nPeer::$instances[$key])) {
358: return CustomerTitleI18nPeer::$instances[$key];
359: }
360: }
361:
362: return null; // just to be explicit
363: }
364:
365: /**
366: * Clear the instance pool.
367: *
368: * @return void
369: */
370: public static function clearInstancePool()
371: {
372: CustomerTitleI18nPeer::$instances = array();
373: }
374:
375: /**
376: * Method to invalidate the instance pool of all tables related to customer_title_i18n
377: * by a foreign key with ON DELETE CASCADE
378: */
379: public static function clearRelatedInstancePool()
380: {
381: }
382:
383: /**
384: * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
385: *
386: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
387: * a multi-column primary key, a serialize()d version of the primary key will be returned.
388: *
389: * @param array $row PropelPDO resultset row.
390: * @param int $startcol The 0-based offset for reading from the resultset row.
391: * @return string A string version of PK or null if the components of primary key in result array are all null.
392: */
393: public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
394: {
395: // If the PK cannot be derived from the row, return null.
396: if ($row[$startcol] === null && $row[$startcol + 1] === null) {
397: return null;
398: }
399:
400: return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
401: }
402:
403: /**
404: * Retrieves the primary key from the DB resultset row
405: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
406: * a multi-column primary key, an array of the primary key columns will be returned.
407: *
408: * @param array $row PropelPDO resultset row.
409: * @param int $startcol The 0-based offset for reading from the resultset row.
410: * @return mixed The primary key of the row
411: */
412: public static function getPrimaryKeyFromRow($row, $startcol = 0)
413: {
414:
415: return array((int) $row[$startcol], (string) $row[$startcol + 1]);
416: }
417:
418: /**
419: * The returned array will contain objects of the default type or
420: * objects that inherit from the default.
421: *
422: * @throws PropelException Any exceptions caught during processing will be
423: * rethrown wrapped into a PropelException.
424: */
425: public static function populateObjects(PDOStatement $stmt)
426: {
427: $results = array();
428:
429: // set the class once to avoid overhead in the loop
430: $cls = CustomerTitleI18nPeer::getOMClass();
431: // populate the object(s)
432: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
433: $key = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
434: if (null !== ($obj = CustomerTitleI18nPeer::getInstanceFromPool($key))) {
435: // We no longer rehydrate the object, since this can cause data loss.
436: // See http://www.propelorm.org/ticket/509
437: // $obj->hydrate($row, 0, true); // rehydrate
438: $results[] = $obj;
439: } else {
440: $obj = new $cls();
441: $obj->hydrate($row);
442: $results[] = $obj;
443: CustomerTitleI18nPeer::addInstanceToPool($obj, $key);
444: } // if key exists
445: }
446: $stmt->closeCursor();
447:
448: return $results;
449: }
450: /**
451: * Populates an object of the default type or an object that inherit from the default.
452: *
453: * @param array $row PropelPDO resultset row.
454: * @param int $startcol The 0-based offset for reading from the resultset row.
455: * @throws PropelException Any exceptions caught during processing will be
456: * rethrown wrapped into a PropelException.
457: * @return array (CustomerTitleI18n object, last column rank)
458: */
459: public static function populateObject($row, $startcol = 0)
460: {
461: $key = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
462: if (null !== ($obj = CustomerTitleI18nPeer::getInstanceFromPool($key))) {
463: // We no longer rehydrate the object, since this can cause data loss.
464: // See http://www.propelorm.org/ticket/509
465: // $obj->hydrate($row, $startcol, true); // rehydrate
466: $col = $startcol + CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS;
467: } else {
468: $cls = CustomerTitleI18nPeer::OM_CLASS;
469: $obj = new $cls();
470: $col = $obj->hydrate($row, $startcol);
471: CustomerTitleI18nPeer::addInstanceToPool($obj, $key);
472: }
473:
474: return array($obj, $col);
475: }
476:
477:
478: /**
479: * Returns the number of rows matching criteria, joining the related CustomerTitle table
480: *
481: * @param Criteria $criteria
482: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
483: * @param PropelPDO $con
484: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
485: * @return int Number of matching rows.
486: */
487: public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
488: {
489: // we're going to modify criteria, so copy it first
490: $criteria = clone $criteria;
491:
492: // We need to set the primary table name, since in the case that there are no WHERE columns
493: // it will be impossible for the BasePeer::createSelectSql() method to determine which
494: // tables go into the FROM clause.
495: $criteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME);
496:
497: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
498: $criteria->setDistinct();
499: }
500:
501: if (!$criteria->hasSelectClause()) {
502: CustomerTitleI18nPeer::addSelectColumns($criteria);
503: }
504:
505: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
506:
507: // Set the correct dbName
508: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
509:
510: if ($con === null) {
511: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
512: }
513:
514: $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior);
515:
516: $stmt = BasePeer::doCount($criteria, $con);
517:
518: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
519: $count = (int) $row[0];
520: } else {
521: $count = 0; // no rows returned; we infer that means 0 matches.
522: }
523: $stmt->closeCursor();
524:
525: return $count;
526: }
527:
528:
529: /**
530: * Selects a collection of CustomerTitleI18n objects pre-filled with their CustomerTitle objects.
531: * @param Criteria $criteria
532: * @param PropelPDO $con
533: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
534: * @return array Array of CustomerTitleI18n objects.
535: * @throws PropelException Any exceptions caught during processing will be
536: * rethrown wrapped into a PropelException.
537: */
538: public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
539: {
540: $criteria = clone $criteria;
541:
542: // Set the correct dbName if it has not been overridden
543: if ($criteria->getDbName() == Propel::getDefaultDB()) {
544: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
545: }
546:
547: CustomerTitleI18nPeer::addSelectColumns($criteria);
548: $startcol = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS;
549: CustomerTitlePeer::addSelectColumns($criteria);
550:
551: $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior);
552:
553: $stmt = BasePeer::doSelect($criteria, $con);
554: $results = array();
555:
556: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
557: $key1 = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
558: if (null !== ($obj1 = CustomerTitleI18nPeer::getInstanceFromPool($key1))) {
559: // We no longer rehydrate the object, since this can cause data loss.
560: // See http://www.propelorm.org/ticket/509
561: // $obj1->hydrate($row, 0, true); // rehydrate
562: } else {
563:
564: $cls = CustomerTitleI18nPeer::getOMClass();
565:
566: $obj1 = new $cls();
567: $obj1->hydrate($row);
568: CustomerTitleI18nPeer::addInstanceToPool($obj1, $key1);
569: } // if $obj1 already loaded
570:
571: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol);
572: if ($key2 !== null) {
573: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
574: if (!$obj2) {
575:
576: $cls = CustomerTitlePeer::getOMClass();
577:
578: $obj2 = new $cls();
579: $obj2->hydrate($row, $startcol);
580: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
581: } // if obj2 already loaded
582:
583: // Add the $obj1 (CustomerTitleI18n) to $obj2 (CustomerTitle)
584: $obj2->addCustomerTitleI18n($obj1);
585:
586: } // if joined row was not null
587:
588: $results[] = $obj1;
589: }
590: $stmt->closeCursor();
591:
592: return $results;
593: }
594:
595:
596: /**
597: * Returns the number of rows matching criteria, joining all related tables
598: *
599: * @param Criteria $criteria
600: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
601: * @param PropelPDO $con
602: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
603: * @return int Number of matching rows.
604: */
605: public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
606: {
607: // we're going to modify criteria, so copy it first
608: $criteria = clone $criteria;
609:
610: // We need to set the primary table name, since in the case that there are no WHERE columns
611: // it will be impossible for the BasePeer::createSelectSql() method to determine which
612: // tables go into the FROM clause.
613: $criteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME);
614:
615: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
616: $criteria->setDistinct();
617: }
618:
619: if (!$criteria->hasSelectClause()) {
620: CustomerTitleI18nPeer::addSelectColumns($criteria);
621: }
622:
623: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
624:
625: // Set the correct dbName
626: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
627:
628: if ($con === null) {
629: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
630: }
631:
632: $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior);
633:
634: $stmt = BasePeer::doCount($criteria, $con);
635:
636: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
637: $count = (int) $row[0];
638: } else {
639: $count = 0; // no rows returned; we infer that means 0 matches.
640: }
641: $stmt->closeCursor();
642:
643: return $count;
644: }
645:
646: /**
647: * Selects a collection of CustomerTitleI18n objects pre-filled with all related objects.
648: *
649: * @param Criteria $criteria
650: * @param PropelPDO $con
651: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
652: * @return array Array of CustomerTitleI18n objects.
653: * @throws PropelException Any exceptions caught during processing will be
654: * rethrown wrapped into a PropelException.
655: */
656: public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
657: {
658: $criteria = clone $criteria;
659:
660: // Set the correct dbName if it has not been overridden
661: if ($criteria->getDbName() == Propel::getDefaultDB()) {
662: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
663: }
664:
665: CustomerTitleI18nPeer::addSelectColumns($criteria);
666: $startcol2 = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS;
667:
668: CustomerTitlePeer::addSelectColumns($criteria);
669: $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS;
670:
671: $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior);
672:
673: $stmt = BasePeer::doSelect($criteria, $con);
674: $results = array();
675:
676: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
677: $key1 = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0);
678: if (null !== ($obj1 = CustomerTitleI18nPeer::getInstanceFromPool($key1))) {
679: // We no longer rehydrate the object, since this can cause data loss.
680: // See http://www.propelorm.org/ticket/509
681: // $obj1->hydrate($row, 0, true); // rehydrate
682: } else {
683: $cls = CustomerTitleI18nPeer::getOMClass();
684:
685: $obj1 = new $cls();
686: $obj1->hydrate($row);
687: CustomerTitleI18nPeer::addInstanceToPool($obj1, $key1);
688: } // if obj1 already loaded
689:
690: // Add objects for joined CustomerTitle rows
691:
692: $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
693: if ($key2 !== null) {
694: $obj2 = CustomerTitlePeer::getInstanceFromPool($key2);
695: if (!$obj2) {
696:
697: $cls = CustomerTitlePeer::getOMClass();
698:
699: $obj2 = new $cls();
700: $obj2->hydrate($row, $startcol2);
701: CustomerTitlePeer::addInstanceToPool($obj2, $key2);
702: } // if obj2 loaded
703:
704: // Add the $obj1 (CustomerTitleI18n) to the collection in $obj2 (CustomerTitle)
705: $obj2->addCustomerTitleI18n($obj1);
706: } // if joined row not null
707:
708: $results[] = $obj1;
709: }
710: $stmt->closeCursor();
711:
712: return $results;
713: }
714:
715: /**
716: * Returns the TableMap related to this peer.
717: * This method is not needed for general use but a specific application could have a need.
718: * @return TableMap
719: * @throws PropelException Any exceptions caught during processing will be
720: * rethrown wrapped into a PropelException.
721: */
722: public static function getTableMap()
723: {
724: return Propel::getDatabaseMap(CustomerTitleI18nPeer::DATABASE_NAME)->getTable(CustomerTitleI18nPeer::TABLE_NAME);
725: }
726:
727: /**
728: * Add a TableMap instance to the database for this peer class.
729: */
730: public static function buildTableMap()
731: {
732: $dbMap = Propel::getDatabaseMap(BaseCustomerTitleI18nPeer::DATABASE_NAME);
733: if (!$dbMap->hasTable(BaseCustomerTitleI18nPeer::TABLE_NAME)) {
734: $dbMap->addTableObject(new CustomerTitleI18nTableMap());
735: }
736: }
737:
738: /**
739: * The class that the Peer will make instances of.
740: *
741: *
742: * @return string ClassName
743: */
744: public static function getOMClass()
745: {
746: return CustomerTitleI18nPeer::OM_CLASS;
747: }
748:
749: /**
750: * Performs an INSERT on the database, given a CustomerTitleI18n or Criteria object.
751: *
752: * @param mixed $values Criteria or CustomerTitleI18n object containing data that is used to create the INSERT statement.
753: * @param PropelPDO $con the PropelPDO connection to use
754: * @return mixed The new primary key.
755: * @throws PropelException Any exceptions caught during processing will be
756: * rethrown wrapped into a PropelException.
757: */
758: public static function doInsert($values, PropelPDO $con = null)
759: {
760: if ($con === null) {
761: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
762: }
763:
764: if ($values instanceof Criteria) {
765: $criteria = clone $values; // rename for clarity
766: } else {
767: $criteria = $values->buildCriteria(); // build Criteria from CustomerTitleI18n object
768: }
769:
770:
771: // Set the correct dbName
772: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
773:
774: try {
775: // use transaction because $criteria could contain info
776: // for more than one table (I guess, conceivably)
777: $con->beginTransaction();
778: $pk = BasePeer::doInsert($criteria, $con);
779: $con->commit();
780: } catch (PropelException $e) {
781: $con->rollBack();
782: throw $e;
783: }
784:
785: return $pk;
786: }
787:
788: /**
789: * Performs an UPDATE on the database, given a CustomerTitleI18n or Criteria object.
790: *
791: * @param mixed $values Criteria or CustomerTitleI18n object containing data that is used to create the UPDATE statement.
792: * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
793: * @return int The number of affected rows (if supported by underlying database driver).
794: * @throws PropelException Any exceptions caught during processing will be
795: * rethrown wrapped into a PropelException.
796: */
797: public static function doUpdate($values, PropelPDO $con = null)
798: {
799: if ($con === null) {
800: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
801: }
802:
803: $selectCriteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME);
804:
805: if ($values instanceof Criteria) {
806: $criteria = clone $values; // rename for clarity
807:
808: $comparison = $criteria->getComparison(CustomerTitleI18nPeer::ID);
809: $value = $criteria->remove(CustomerTitleI18nPeer::ID);
810: if ($value) {
811: $selectCriteria->add(CustomerTitleI18nPeer::ID, $value, $comparison);
812: } else {
813: $selectCriteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME);
814: }
815:
816: $comparison = $criteria->getComparison(CustomerTitleI18nPeer::LOCALE);
817: $value = $criteria->remove(CustomerTitleI18nPeer::LOCALE);
818: if ($value) {
819: $selectCriteria->add(CustomerTitleI18nPeer::LOCALE, $value, $comparison);
820: } else {
821: $selectCriteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME);
822: }
823:
824: } else { // $values is CustomerTitleI18n object
825: $criteria = $values->buildCriteria(); // gets full criteria
826: $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
827: }
828:
829: // set the correct dbName
830: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
831:
832: return BasePeer::doUpdate($selectCriteria, $criteria, $con);
833: }
834:
835: /**
836: * Deletes all rows from the customer_title_i18n table.
837: *
838: * @param PropelPDO $con the connection to use
839: * @return int The number of affected rows (if supported by underlying database driver).
840: * @throws PropelException
841: */
842: public static function doDeleteAll(PropelPDO $con = null)
843: {
844: if ($con === null) {
845: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
846: }
847: $affectedRows = 0; // initialize var to track total num of affected rows
848: try {
849: // use transaction because $criteria could contain info
850: // for more than one table or we could emulating ON DELETE CASCADE, etc.
851: $con->beginTransaction();
852: $affectedRows += BasePeer::doDeleteAll(CustomerTitleI18nPeer::TABLE_NAME, $con, CustomerTitleI18nPeer::DATABASE_NAME);
853: // Because this db requires some delete cascade/set null emulation, we have to
854: // clear the cached instance *after* the emulation has happened (since
855: // instances get re-added by the select statement contained therein).
856: CustomerTitleI18nPeer::clearInstancePool();
857: CustomerTitleI18nPeer::clearRelatedInstancePool();
858: $con->commit();
859:
860: return $affectedRows;
861: } catch (PropelException $e) {
862: $con->rollBack();
863: throw $e;
864: }
865: }
866:
867: /**
868: * Performs a DELETE on the database, given a CustomerTitleI18n or Criteria object OR a primary key value.
869: *
870: * @param mixed $values Criteria or CustomerTitleI18n object or primary key or array of primary keys
871: * which is used to create the DELETE statement
872: * @param PropelPDO $con the connection to use
873: * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
874: * if supported by native driver or if emulated using Propel.
875: * @throws PropelException Any exceptions caught during processing will be
876: * rethrown wrapped into a PropelException.
877: */
878: public static function doDelete($values, PropelPDO $con = null)
879: {
880: if ($con === null) {
881: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
882: }
883:
884: if ($values instanceof Criteria) {
885: // invalidate the cache for all objects of this type, since we have no
886: // way of knowing (without running a query) what objects should be invalidated
887: // from the cache based on this Criteria.
888: CustomerTitleI18nPeer::clearInstancePool();
889: // rename for clarity
890: $criteria = clone $values;
891: } elseif ($values instanceof CustomerTitleI18n) { // it's a model object
892: // invalidate the cache for this single object
893: CustomerTitleI18nPeer::removeInstanceFromPool($values);
894: // create criteria based on pk values
895: $criteria = $values->buildPkeyCriteria();
896: } else { // it's a primary key, or an array of pks
897: $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME);
898: // primary key is composite; we therefore, expect
899: // the primary key passed to be an array of pkey values
900: if (count($values) == count($values, COUNT_RECURSIVE)) {
901: // array is not multi-dimensional
902: $values = array($values);
903: }
904: foreach ($values as $value) {
905: $criterion = $criteria->getNewCriterion(CustomerTitleI18nPeer::ID, $value[0]);
906: $criterion->addAnd($criteria->getNewCriterion(CustomerTitleI18nPeer::LOCALE, $value[1]));
907: $criteria->addOr($criterion);
908: // we can invalidate the cache for this single PK
909: CustomerTitleI18nPeer::removeInstanceFromPool($value);
910: }
911: }
912:
913: // Set the correct dbName
914: $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME);
915:
916: $affectedRows = 0; // initialize var to track total num of affected rows
917:
918: try {
919: // use transaction because $criteria could contain info
920: // for more than one table or we could emulating ON DELETE CASCADE, etc.
921: $con->beginTransaction();
922:
923: $affectedRows += BasePeer::doDelete($criteria, $con);
924: CustomerTitleI18nPeer::clearRelatedInstancePool();
925: $con->commit();
926:
927: return $affectedRows;
928: } catch (PropelException $e) {
929: $con->rollBack();
930: throw $e;
931: }
932: }
933:
934: /**
935: * Validates all modified columns of given CustomerTitleI18n object.
936: * If parameter $columns is either a single column name or an array of column names
937: * than only those columns are validated.
938: *
939: * NOTICE: This does not apply to primary or foreign keys for now.
940: *
941: * @param CustomerTitleI18n $obj The object to validate.
942: * @param mixed $cols Column name or array of column names.
943: *
944: * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
945: */
946: public static function doValidate($obj, $cols = null)
947: {
948: $columns = array();
949:
950: if ($cols) {
951: $dbMap = Propel::getDatabaseMap(CustomerTitleI18nPeer::DATABASE_NAME);
952: $tableMap = $dbMap->getTable(CustomerTitleI18nPeer::TABLE_NAME);
953:
954: if (! is_array($cols)) {
955: $cols = array($cols);
956: }
957:
958: foreach ($cols as $colName) {
959: if ($tableMap->hasColumn($colName)) {
960: $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
961: $columns[$colName] = $obj->$get();
962: }
963: }
964: } else {
965:
966: }
967:
968: return BasePeer::doValidate(CustomerTitleI18nPeer::DATABASE_NAME, CustomerTitleI18nPeer::TABLE_NAME, $columns);
969: }
970:
971: /**
972: * Retrieve object using using composite pkey values.
973: * @param int $id
974: * @param string $locale
975: * @param PropelPDO $con
976: * @return CustomerTitleI18n
977: */
978: public static function retrieveByPK($id, $locale, PropelPDO $con = null) {
979: $_instancePoolKey = serialize(array((string) $id, (string) $locale));
980: if (null !== ($obj = CustomerTitleI18nPeer::getInstanceFromPool($_instancePoolKey))) {
981: return $obj;
982: }
983:
984: if ($con === null) {
985: $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
986: }
987: $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME);
988: $criteria->add(CustomerTitleI18nPeer::ID, $id);
989: $criteria->add(CustomerTitleI18nPeer::LOCALE, $locale);
990: $v = CustomerTitleI18nPeer::doSelect($criteria, $con);
991:
992: return !empty($v) ? $v[0] : null;
993: }
994: } // BaseCustomerTitleI18nPeer
995:
996: // This is the static code needed to register the TableMap for this table with the main Propel class.
997: //
998: BaseCustomerTitleI18nPeer::buildTableMap();
999:
1000: