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