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