       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\FolderPeer;
      13: use Thelia\Model\FolderVersion;
      14: use Thelia\Model\FolderVersionPeer;
      15: use Thelia\Model\map\FolderVersionTableMap;
      16:
      17: /**
      18:  * Base static class for performing query and update operations on the 'folder_version' table.
      19:  *
      20:  *
      21:  *
      22:  * @package propel.generator.Thelia.Model.om
      23:  */
      24: abstract class BaseFolderVersionPeer
      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 = 'folder_version';
      32:
      33:     /** the related Propel class for this table */
      34:     const OM_CLASS = 'Thelia\\Model\\FolderVersion';
      35:
      36:     /** the related TableMap class for this table */
      37:     const TM_CLASS = 'FolderVersionTableMap';
      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 = 'folder_version.id';
      50:
      51:     /** the column name for the parent field */
      52:     const PARENT = 'folder_version.parent';
      53:
      54:     /** the column name for the link field */
      55:     const LINK = 'folder_version.link';
      56:
      57:     /** the column name for the visible field */
      58:     const VISIBLE = 'folder_version.visible';
      59:
      60:     /** the column name for the position field */
      61:     const POSITION = 'folder_version.position';
      62:
      63:     /** the column name for the created_at field */
      64:     const CREATED_AT = 'folder_version.created_at';
      65:
      66:     /** the column name for the updated_at field */
      67:     const UPDATED_AT = 'folder_version.updated_at';
      68:
      69:     /** the column name for the version field */
      70:     const VERSION = 'folder_version.version';
      71:
      72:     /** the column name for the version_created_at field */
      73:     const VERSION_CREATED_AT = 'folder_version.version_created_at';
      74:
      75:     /** the column name for the version_created_by field */
      76:     const VERSION_CREATED_BY = 'folder_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 FolderVersion objects.
      83:      * This must be public so that other peer classes can access this when hydrating from JOIN
      84:      * queries.
      85:      * @var        array FolderVersion[]
      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. FolderVersionPeer::$fieldNames[FolderVersionPeer::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 (FolderVersionPeer::ID, FolderVersionPeer::PARENT, FolderVersionPeer::LINK, FolderVersionPeer::VISIBLE, FolderVersionPeer::POSITION, FolderVersionPeer::CREATED_AT, FolderVersionPeer::UPDATED_AT, FolderVersionPeer::VERSION, FolderVersionPeer::VERSION_CREATED_AT, FolderVersionPeer::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. FolderVersionPeer::$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 (FolderVersionPeer::ID => 0, FolderVersionPeer::PARENT => 1, FolderVersionPeer::LINK => 2, FolderVersionPeer::VISIBLE => 3, FolderVersionPeer::POSITION => 4, FolderVersionPeer::CREATED_AT => 5, FolderVersionPeer::UPDATED_AT => 6, FolderVersionPeer::VERSION => 7, FolderVersionPeer::VERSION_CREATED_AT => 8, FolderVersionPeer::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 = FolderVersionPeer::getFieldNames($toType);
     133:         $key = isset(FolderVersionPeer::$fieldKeys[$fromType][$name]) ? FolderVersionPeer::$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(FolderVersionPeer::$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, FolderVersionPeer::$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 FolderVersionPeer::$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. FolderVersionPeer::COLUMN_NAME).
     169:      * @return string
     170:      */
     171:     public static function alias($alias, $column)
     172:     {
     173:         return str_replace(FolderVersionPeer::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(FolderVersionPeer::ID);
     192:             $criteria->addSelectColumn(FolderVersionPeer::PARENT);
     193:             $criteria->addSelectColumn(FolderVersionPeer::LINK);
     194:             $criteria->addSelectColumn(FolderVersionPeer::VISIBLE);
     195:             $criteria->addSelectColumn(FolderVersionPeer::POSITION);
     196:             $criteria->addSelectColumn(FolderVersionPeer::CREATED_AT);
     197:             $criteria->addSelectColumn(FolderVersionPeer::UPDATED_AT);
     198:             $criteria->addSelectColumn(FolderVersionPeer::VERSION);
     199:             $criteria->addSelectColumn(FolderVersionPeer::VERSION_CREATED_AT);
     200:             $criteria->addSelectColumn(FolderVersionPeer::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(FolderVersionPeer::TABLE_NAME);
     232:
     233:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     234:             $criteria->setDistinct();
     235:         }
     236:
     237:         if (!$criteria->hasSelectClause()) {
     238:             FolderVersionPeer::addSelectColumns($criteria);
     239:         }
     240:
     241:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     242:         $criteria->setDbName(FolderVersionPeer::DATABASE_NAME); // Set the correct dbName
     243:
     244:         if ($con === null) {
     245:             $con = Propel::getConnection(FolderVersionPeer::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                 FolderVersion
     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 = FolderVersionPeer::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 FolderVersionPeer::populateObjects(FolderVersionPeer::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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     309:         }
     310:
     311:         if (!$criteria->hasSelectClause()) {
     312:             $criteria = clone $criteria;
     313:             FolderVersionPeer::addSelectColumns($criteria);
     314:         }
     315:
     316:         // Set the correct dbName
     317:         $criteria->setDbName(FolderVersionPeer::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      FolderVersion $obj A FolderVersion 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:             FolderVersionPeer::$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 FolderVersion 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 FolderVersion) {
     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 FolderVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
     367:                 throw $e;
     368:             }
     369:
     370:             unset(FolderVersionPeer::$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   FolderVersion 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(FolderVersionPeer::$instances[$key])) {
     388:                 return FolderVersionPeer::$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 (FolderVersionPeer::$instances as $instance)
     405:         {
     406:           $instance->clearAllReferences(true);
     407:         }
     408:       }
     409:         FolderVersionPeer::$instances = array();
     410:     }
     411:
     412:     /**
     413:      * Method to invalidate the instance pool of all tables related to folder_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 = FolderVersionPeer::getOMClass();
     468:         // populate the object(s)
     469:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     470:             $key = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
     471:             if (null !== ($obj = FolderVersionPeer::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:                 FolderVersionPeer::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 (FolderVersion object, last column rank)
     495:      */
     496:     public static function populateObject($row, $startcol = 0)
     497:     {
     498:         $key = FolderVersionPeer::getPrimaryKeyHashFromRow($row, $startcol);
     499:         if (null !== ($obj = FolderVersionPeer::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 + FolderVersionPeer::NUM_HYDRATE_COLUMNS;
     504:         } else {
     505:             $cls = FolderVersionPeer::OM_CLASS;
     506:             $obj = new $cls();
     507:             $col = $obj->hydrate($row, $startcol);
     508:             FolderVersionPeer::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 Folder 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 doCountJoinFolder(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(FolderVersionPeer::TABLE_NAME);
     533:
     534:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     535:             $criteria->setDistinct();
     536:         }
     537:
     538:         if (!$criteria->hasSelectClause()) {
     539:             FolderVersionPeer::addSelectColumns($criteria);
     540:         }
     541:
     542:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     543:
     544:         // Set the correct dbName
     545:         $criteria->setDbName(FolderVersionPeer::DATABASE_NAME);
     546:
     547:         if ($con === null) {
     548:             $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     549:         }
     550:
     551:         $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::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 FolderVersion objects pre-filled with their Folder 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 FolderVersion objects.
     572:      * @throws PropelException Any exceptions caught during processing will be
     573:      *       rethrown wrapped into a PropelException.
     574:      */
     575:     public static function doSelectJoinFolder(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(FolderVersionPeer::DATABASE_NAME);
     582:         }
     583:
     584:         FolderVersionPeer::addSelectColumns($criteria);
     585:         $startcol = FolderVersionPeer::NUM_HYDRATE_COLUMNS;
     586:         FolderPeer::addSelectColumns($criteria);
     587:
     588:         $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::ID, $join_behavior);
     589:
     590:         $stmt = BasePeer::doSelect($criteria, $con);
     591:         $results = array();
     592:
     593:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     594:             $key1 = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
     595:             if (null !== ($obj1 = FolderVersionPeer::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 = FolderVersionPeer::getOMClass();
     602:
     603:                 $obj1 = new $cls();
     604:                 $obj1->hydrate($row);
     605:                 FolderVersionPeer::addInstanceToPool($obj1, $key1);
     606:             } // if $obj1 already loaded
     607:
     608:             $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol);
     609:             if ($key2 !== null) {
     610:                 $obj2 = FolderPeer::getInstanceFromPool($key2);
     611:                 if (!$obj2) {
     612:
     613:                     $cls = FolderPeer::getOMClass();
     614:
     615:                     $obj2 = new $cls();
     616:                     $obj2->hydrate($row, $startcol);
     617:                     FolderPeer::addInstanceToPool($obj2, $key2);
     618:                 } // if obj2 already loaded
     619:
     620:                 // Add the $obj1 (FolderVersion) to $obj2 (Folder)
     621:                 $obj2->addFolderVersion($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(FolderVersionPeer::TABLE_NAME);
     651:
     652:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     653:             $criteria->setDistinct();
     654:         }
     655:
     656:         if (!$criteria->hasSelectClause()) {
     657:             FolderVersionPeer::addSelectColumns($criteria);
     658:         }
     659:
     660:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     661:
     662:         // Set the correct dbName
     663:         $criteria->setDbName(FolderVersionPeer::DATABASE_NAME);
     664:
     665:         if ($con === null) {
     666:             $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     667:         }
     668:
     669:         $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::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 FolderVersion 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 FolderVersion 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(FolderVersionPeer::DATABASE_NAME);
     700:         }
     701:
     702:         FolderVersionPeer::addSelectColumns($criteria);
     703:         $startcol2 = FolderVersionPeer::NUM_HYDRATE_COLUMNS;
     704:
     705:         FolderPeer::addSelectColumns($criteria);
     706:         $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS;
     707:
     708:         $criteria->addJoin(FolderVersionPeer::ID, FolderPeer::ID, $join_behavior);
     709:
     710:         $stmt = BasePeer::doSelect($criteria, $con);
     711:         $results = array();
     712:
     713:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     714:             $key1 = FolderVersionPeer::getPrimaryKeyHashFromRow($row, 0);
     715:             if (null !== ($obj1 = FolderVersionPeer::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 = FolderVersionPeer::getOMClass();
     721:
     722:                 $obj1 = new $cls();
     723:                 $obj1->hydrate($row);
     724:                 FolderVersionPeer::addInstanceToPool($obj1, $key1);
     725:             } // if obj1 already loaded
     726:
     727:             // Add objects for joined Folder rows
     728:
     729:             $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol2);
     730:             if ($key2 !== null) {
     731:                 $obj2 = FolderPeer::getInstanceFromPool($key2);
     732:                 if (!$obj2) {
     733:
     734:                     $cls = FolderPeer::getOMClass();
     735:
     736:                     $obj2 = new $cls();
     737:                     $obj2->hydrate($row, $startcol2);
     738:                     FolderPeer::addInstanceToPool($obj2, $key2);
     739:                 } // if obj2 loaded
     740:
     741:                 // Add the $obj1 (FolderVersion) to the collection in $obj2 (Folder)
     742:                 $obj2->addFolderVersion($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(FolderVersionPeer::DATABASE_NAME)->getTable(FolderVersionPeer::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(BaseFolderVersionPeer::DATABASE_NAME);
     770:       if (!$dbMap->hasTable(BaseFolderVersionPeer::TABLE_NAME)) {
     771:         $dbMap->addTableObject(new FolderVersionTableMap());
     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 FolderVersionPeer::OM_CLASS;
     784:     }
     785:
     786:     /**
     787:      * Performs an INSERT on the database, given a FolderVersion or Criteria object.
     788:      *
     789:      * @param      mixed $values Criteria or FolderVersion 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(FolderVersionPeer::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 FolderVersion object
     805:         }
     806:
     807:
     808:         // Set the correct dbName
     809:         $criteria->setDbName(FolderVersionPeer::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 FolderVersion or Criteria object.
     827:      *
     828:      * @param      mixed $values Criteria or FolderVersion 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(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     838:         }
     839:
     840:         $selectCriteria = new Criteria(FolderVersionPeer::DATABASE_NAME);
     841:
     842:         if ($values instanceof Criteria) {
     843:             $criteria = clone $values; // rename for clarity
     844:
     845:             $comparison = $criteria->getComparison(FolderVersionPeer::ID);
     846:             $value = $criteria->remove(FolderVersionPeer::ID);
     847:             if ($value) {
     848:                 $selectCriteria->add(FolderVersionPeer::ID, $value, $comparison);
     849:             } else {
     850:                 $selectCriteria->setPrimaryTableName(FolderVersionPeer::TABLE_NAME);
     851:             }
     852:
     853:             $comparison = $criteria->getComparison(FolderVersionPeer::VERSION);
     854:             $value = $criteria->remove(FolderVersionPeer::VERSION);
     855:             if ($value) {
     856:                 $selectCriteria->add(FolderVersionPeer::VERSION, $value, $comparison);
     857:             } else {
     858:                 $selectCriteria->setPrimaryTableName(FolderVersionPeer::TABLE_NAME);
     859:             }
     860:
     861:         } else { // $values is FolderVersion 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(FolderVersionPeer::DATABASE_NAME);
     868:
     869:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
     870:     }
     871:
     872:     /**
     873:      * Deletes all rows from the folder_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(FolderVersionPeer::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(FolderVersionPeer::TABLE_NAME, $con, FolderVersionPeer::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:             FolderVersionPeer::clearInstancePool();
     894:             FolderVersionPeer::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 FolderVersion or Criteria object OR a primary key value.
     906:      *
     907:      * @param      mixed $values Criteria or FolderVersion 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(FolderVersionPeer::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:             FolderVersionPeer::clearInstancePool();
     926:             // rename for clarity
     927:             $criteria = clone $values;
     928:         } elseif ($values instanceof FolderVersion) { // it's a model object
     929:             // invalidate the cache for this single object
     930:             FolderVersionPeer::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(FolderVersionPeer::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(FolderVersionPeer::ID, $value[0]);
     943:                 $criterion->addAnd($criteria->getNewCriterion(FolderVersionPeer::VERSION, $value[1]));
     944:                 $criteria->addOr($criterion);
     945:                 // we can invalidate the cache for this single PK
     946:                 FolderVersionPeer::removeInstanceFromPool($value);
     947:             }
     948:         }
     949:
     950:         // Set the correct dbName
     951:         $criteria->setDbName(FolderVersionPeer::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:             FolderVersionPeer::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 FolderVersion 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      FolderVersion $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(FolderVersionPeer::DATABASE_NAME);
     989:             $tableMap = $dbMap->getTable(FolderVersionPeer::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(FolderVersionPeer::DATABASE_NAME, FolderVersionPeer::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   FolderVersion
    1014:      */
    1015:     public static function retrieveByPK($id, $version, PropelPDO $con = null) {
    1016:         $_instancePoolKey = serialize(array((string) $id, (string) $version));
    1017:          if (null !== ($obj = FolderVersionPeer::getInstanceFromPool($_instancePoolKey))) {
    1018:              return $obj;
    1019:         }
    1020:
    1021:         if ($con === null) {
    1022:             $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1023:         }
    1024:         $criteria = new Criteria(FolderVersionPeer::DATABASE_NAME);
    1025:         $criteria->add(FolderVersionPeer::ID, $id);
    1026:         $criteria->add(FolderVersionPeer::VERSION, $version);
    1027:         $v = FolderVersionPeer::doSelect($criteria, $con);
    1028:
    1029:         return !empty($v) ? $v[0] : null;
    1030:     }
    1031: } // BaseFolderVersionPeer
    1032:
    1033: // This is the static code needed to register the TableMap for this table with the main Propel class.
    1034: //
    1035: BaseFolderVersionPeer::buildTableMap();
    1036:
    1037: