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

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