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