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