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