# File core/lib/Thelia/Model/om/BaseMessageVersionPeer.php | thelia

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