# File core/lib/Thelia/Model/om/BaseImageI18nPeer.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\ImageI18n;
      13: use Thelia\Model\ImageI18nPeer;
      14: use Thelia\Model\ImagePeer;
      15: use Thelia\Model\map\ImageI18nTableMap;
      16:
      17: /**
      18:  * Base static class for performing query and update operations on the 'image_i18n' table.
      19:  *
      20:  *
      21:  *
      22:  * @package propel.generator.Thelia.Model.om
      23:  */
      24: abstract class BaseImageI18nPeer
      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 = 'image_i18n';
      32:
      33:     /** the related Propel class for this table */
      34:     const OM_CLASS = 'Thelia\\Model\\ImageI18n';
      35:
      36:     /** the related TableMap class for this table */
      37:     const TM_CLASS = 'ImageI18nTableMap';
      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 = 'image_i18n.ID';
      50:
      51:     /** the column name for the LOCALE field */
      52:     const LOCALE = 'image_i18n.LOCALE';
      53:
      54:     /** the column name for the TITLE field */
      55:     const TITLE = 'image_i18n.TITLE';
      56:
      57:     /** the column name for the DESCRIPTION field */
      58:     const DESCRIPTION = 'image_i18n.DESCRIPTION';
      59:
      60:     /** the column name for the CHAPO field */
      61:     const CHAPO = 'image_i18n.CHAPO';
      62:
      63:     /** the column name for the POSTSCRIPTUM field */
      64:     const POSTSCRIPTUM = 'image_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 ImageI18n objects.
      71:      * This must be public so that other peer classes can access this when hydrating from JOIN
      72:      * queries.
      73:      * @var        array ImageI18n[]
      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. ImageI18nPeer::$fieldNames[ImageI18nPeer::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 (ImageI18nPeer::ID, ImageI18nPeer::LOCALE, ImageI18nPeer::TITLE, ImageI18nPeer::DESCRIPTION, ImageI18nPeer::CHAPO, ImageI18nPeer::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. ImageI18nPeer::$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 (ImageI18nPeer::ID => 0, ImageI18nPeer::LOCALE => 1, ImageI18nPeer::TITLE => 2, ImageI18nPeer::DESCRIPTION => 3, ImageI18nPeer::CHAPO => 4, ImageI18nPeer::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 = ImageI18nPeer::getFieldNames($toType);
     121:         $key = isset(ImageI18nPeer::$fieldKeys[$fromType][$name]) ? ImageI18nPeer::$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(ImageI18nPeer::$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, ImageI18nPeer::$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 ImageI18nPeer::$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. ImageI18nPeer::COLUMN_NAME).
     157:      * @return string
     158:      */
     159:     public static function alias($alias, $column)
     160:     {
     161:         return str_replace(ImageI18nPeer::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(ImageI18nPeer::ID);
     180:             $criteria->addSelectColumn(ImageI18nPeer::LOCALE);
     181:             $criteria->addSelectColumn(ImageI18nPeer::TITLE);
     182:             $criteria->addSelectColumn(ImageI18nPeer::DESCRIPTION);
     183:             $criteria->addSelectColumn(ImageI18nPeer::CHAPO);
     184:             $criteria->addSelectColumn(ImageI18nPeer::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(ImageI18nPeer::TABLE_NAME);
     212:
     213:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     214:             $criteria->setDistinct();
     215:         }
     216:
     217:         if (!$criteria->hasSelectClause()) {
     218:             ImageI18nPeer::addSelectColumns($criteria);
     219:         }
     220:
     221:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     222:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); // Set the correct dbName
     223:
     224:         if ($con === null) {
     225:             $con = Propel::getConnection(ImageI18nPeer::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                 ImageI18n
     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 = ImageI18nPeer::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 ImageI18nPeer::populateObjects(ImageI18nPeer::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 durirectly (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(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     289:         }
     290:
     291:         if (!$criteria->hasSelectClause()) {
     292:             $criteria = clone $criteria;
     293:             ImageI18nPeer::addSelectColumns($criteria);
     294:         }
     295:
     296:         // Set the correct dbName
     297:         $criteria->setDbName(ImageI18nPeer::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      ImageI18n $obj A ImageI18n 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:             ImageI18nPeer::$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 ImageI18n 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 ImageI18n) {
     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 ImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
     347:                 throw $e;
     348:             }
     349:
     350:             unset(ImageI18nPeer::$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   ImageI18n 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(ImageI18nPeer::$instances[$key])) {
     368:                 return ImageI18nPeer::$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()
     381:     {
     382:         ImageI18nPeer::$instances = array();
     383:     }
     384:
     385:     /**
     386:      * Method to invalidate the instance pool of all tables related to image_i18n
     387:      * by a foreign key with ON DELETE CASCADE
     388:      */
     389:     public static function clearRelatedInstancePool()
     390:     {
     391:     }
     392:
     393:     /**
     394:      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
     395:      *
     396:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     397:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
     398:      *
     399:      * @param      array $row PropelPDO resultset row.
     400:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     401:      * @return string A string version of PK or null if the components of primary key in result array are all null.
     402:      */
     403:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
     404:     {
     405:         // If the PK cannot be derived from the row, return null.
     406:         if ($row[$startcol] === null && $row[$startcol + 1] === null) {
     407:             return null;
     408:         }
     409:
     410:         return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1]));
     411:     }
     412:
     413:     /**
     414:      * Retrieves the primary key from the DB resultset row
     415:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     416:      * a multi-column primary key, an array of the primary key columns will be returned.
     417:      *
     418:      * @param      array $row PropelPDO resultset row.
     419:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     420:      * @return mixed The primary key of the row
     421:      */
     422:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
     423:     {
     424:
     425:         return array((int) $row[$startcol], (string) $row[$startcol + 1]);
     426:     }
     427:
     428:     /**
     429:      * The returned array will contain objects of the default type or
     430:      * objects that inherit from the default.
     431:      *
     432:      * @throws PropelException Any exceptions caught during processing will be
     433:      *       rethrown wrapped into a PropelException.
     434:      */
     435:     public static function populateObjects(PDOStatement $stmt)
     436:     {
     437:         $results = array();
     438:
     439:         // set the class once to avoid overhead in the loop
     440:         $cls = ImageI18nPeer::getOMClass();
     441:         // populate the object(s)
     442:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     443:             $key = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0);
     444:             if (null !== ($obj = ImageI18nPeer::getInstanceFromPool($key))) {
     445:                 // We no longer rehydrate the object, since this can cause data loss.
     446:                 // See http://www.propelorm.org/ticket/509
     447:                 // $obj->hydrate($row, 0, true); // rehydrate
     448:                 $results[] = $obj;
     449:             } else {
     450:                 $obj = new $cls();
     451:                 $obj->hydrate($row);
     452:                 $results[] = $obj;
     453:                 ImageI18nPeer::addInstanceToPool($obj, $key);
     454:             } // if key exists
     455:         }
     456:         $stmt->closeCursor();
     457:
     458:         return $results;
     459:     }
     460:     /**
     461:      * Populates an object of the default type or an object that inherit from the default.
     462:      *
     463:      * @param      array $row PropelPDO resultset row.
     464:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     465:      * @throws PropelException Any exceptions caught during processing will be
     466:      *       rethrown wrapped into a PropelException.
     467:      * @return array (ImageI18n object, last column rank)
     468:      */
     469:     public static function populateObject($row, $startcol = 0)
     470:     {
     471:         $key = ImageI18nPeer::getPrimaryKeyHashFromRow($row, $startcol);
     472:         if (null !== ($obj = ImageI18nPeer::getInstanceFromPool($key))) {
     473:             // We no longer rehydrate the object, since this can cause data loss.
     474:             // See http://www.propelorm.org/ticket/509
     475:             // $obj->hydrate($row, $startcol, true); // rehydrate
     476:             $col = $startcol + ImageI18nPeer::NUM_HYDRATE_COLUMNS;
     477:         } else {
     478:             $cls = ImageI18nPeer::OM_CLASS;
     479:             $obj = new $cls();
     480:             $col = $obj->hydrate($row, $startcol);
     481:             ImageI18nPeer::addInstanceToPool($obj, $key);
     482:         }
     483:
     484:         return array($obj, $col);
     485:     }
     486:
     487:
     488:     /**
     489:      * Returns the number of rows matching criteria, joining the related Image table
     490:      *
     491:      * @param      Criteria $criteria
     492:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     493:      * @param      PropelPDO $con
     494:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     495:      * @return int Number of matching rows.
     496:      */
     497:     public static function doCountJoinImage(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     498:     {
     499:         // we're going to modify criteria, so copy it first
     500:         $criteria = clone $criteria;
     501:
     502:         // We need to set the primary table name, since in the case that there are no WHERE columns
     503:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     504:         // tables go into the FROM clause.
     505:         $criteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME);
     506:
     507:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     508:             $criteria->setDistinct();
     509:         }
     510:
     511:         if (!$criteria->hasSelectClause()) {
     512:             ImageI18nPeer::addSelectColumns($criteria);
     513:         }
     514:
     515:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     516:
     517:         // Set the correct dbName
     518:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     519:
     520:         if ($con === null) {
     521:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     522:         }
     523:
     524:         $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior);
     525:
     526:         $stmt = BasePeer::doCount($criteria, $con);
     527:
     528:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     529:             $count = (int) $row[0];
     530:         } else {
     531:             $count = 0; // no rows returned; we infer that means 0 matches.
     532:         }
     533:         $stmt->closeCursor();
     534:
     535:         return $count;
     536:     }
     537:
     538:
     539:     /**
     540:      * Selects a collection of ImageI18n objects pre-filled with their Image objects.
     541:      * @param      Criteria  $criteria
     542:      * @param      PropelPDO $con
     543:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     544:      * @return array           Array of ImageI18n objects.
     545:      * @throws PropelException Any exceptions caught during processing will be
     546:      *       rethrown wrapped into a PropelException.
     547:      */
     548:     public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     549:     {
     550:         $criteria = clone $criteria;
     551:
     552:         // Set the correct dbName if it has not been overridden
     553:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     554:             $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     555:         }
     556:
     557:         ImageI18nPeer::addSelectColumns($criteria);
     558:         $startcol = ImageI18nPeer::NUM_HYDRATE_COLUMNS;
     559:         ImagePeer::addSelectColumns($criteria);
     560:
     561:         $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior);
     562:
     563:         $stmt = BasePeer::doSelect($criteria, $con);
     564:         $results = array();
     565:
     566:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     567:             $key1 = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0);
     568:             if (null !== ($obj1 = ImageI18nPeer::getInstanceFromPool($key1))) {
     569:                 // We no longer rehydrate the object, since this can cause data loss.
     570:                 // See http://www.propelorm.org/ticket/509
     571:                 // $obj1->hydrate($row, 0, true); // rehydrate
     572:             } else {
     573:
     574:                 $cls = ImageI18nPeer::getOMClass();
     575:
     576:                 $obj1 = new $cls();
     577:                 $obj1->hydrate($row);
     578:                 ImageI18nPeer::addInstanceToPool($obj1, $key1);
     579:             } // if $obj1 already loaded
     580:
     581:             $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol);
     582:             if ($key2 !== null) {
     583:                 $obj2 = ImagePeer::getInstanceFromPool($key2);
     584:                 if (!$obj2) {
     585:
     586:                     $cls = ImagePeer::getOMClass();
     587:
     588:                     $obj2 = new $cls();
     589:                     $obj2->hydrate($row, $startcol);
     590:                     ImagePeer::addInstanceToPool($obj2, $key2);
     591:                 } // if obj2 already loaded
     592:
     593:                 // Add the $obj1 (ImageI18n) to $obj2 (Image)
     594:                 $obj2->addImageI18n($obj1);
     595:
     596:             } // if joined row was not null
     597:
     598:             $results[] = $obj1;
     599:         }
     600:         $stmt->closeCursor();
     601:
     602:         return $results;
     603:     }
     604:
     605:
     606:     /**
     607:      * Returns the number of rows matching criteria, joining all related tables
     608:      *
     609:      * @param      Criteria $criteria
     610:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     611:      * @param      PropelPDO $con
     612:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     613:      * @return int Number of matching rows.
     614:      */
     615:     public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     616:     {
     617:         // we're going to modify criteria, so copy it first
     618:         $criteria = clone $criteria;
     619:
     620:         // We need to set the primary table name, since in the case that there are no WHERE columns
     621:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     622:         // tables go into the FROM clause.
     623:         $criteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME);
     624:
     625:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     626:             $criteria->setDistinct();
     627:         }
     628:
     629:         if (!$criteria->hasSelectClause()) {
     630:             ImageI18nPeer::addSelectColumns($criteria);
     631:         }
     632:
     633:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     634:
     635:         // Set the correct dbName
     636:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     637:
     638:         if ($con === null) {
     639:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     640:         }
     641:
     642:         $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior);
     643:
     644:         $stmt = BasePeer::doCount($criteria, $con);
     645:
     646:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     647:             $count = (int) $row[0];
     648:         } else {
     649:             $count = 0; // no rows returned; we infer that means 0 matches.
     650:         }
     651:         $stmt->closeCursor();
     652:
     653:         return $count;
     654:     }
     655:
     656:     /**
     657:      * Selects a collection of ImageI18n objects pre-filled with all related objects.
     658:      *
     659:      * @param      Criteria  $criteria
     660:      * @param      PropelPDO $con
     661:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     662:      * @return array           Array of ImageI18n objects.
     663:      * @throws PropelException Any exceptions caught during processing will be
     664:      *       rethrown wrapped into a PropelException.
     665:      */
     666:     public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     667:     {
     668:         $criteria = clone $criteria;
     669:
     670:         // Set the correct dbName if it has not been overridden
     671:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     672:             $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     673:         }
     674:
     675:         ImageI18nPeer::addSelectColumns($criteria);
     676:         $startcol2 = ImageI18nPeer::NUM_HYDRATE_COLUMNS;
     677:
     678:         ImagePeer::addSelectColumns($criteria);
     679:         $startcol3 = $startcol2 + ImagePeer::NUM_HYDRATE_COLUMNS;
     680:
     681:         $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior);
     682:
     683:         $stmt = BasePeer::doSelect($criteria, $con);
     684:         $results = array();
     685:
     686:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     687:             $key1 = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0);
     688:             if (null !== ($obj1 = ImageI18nPeer::getInstanceFromPool($key1))) {
     689:                 // We no longer rehydrate the object, since this can cause data loss.
     690:                 // See http://www.propelorm.org/ticket/509
     691:                 // $obj1->hydrate($row, 0, true); // rehydrate
     692:             } else {
     693:                 $cls = ImageI18nPeer::getOMClass();
     694:
     695:                 $obj1 = new $cls();
     696:                 $obj1->hydrate($row);
     697:                 ImageI18nPeer::addInstanceToPool($obj1, $key1);
     698:             } // if obj1 already loaded
     699:
     700:             // Add objects for joined Image rows
     701:
     702:             $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol2);
     703:             if ($key2 !== null) {
     704:                 $obj2 = ImagePeer::getInstanceFromPool($key2);
     705:                 if (!$obj2) {
     706:
     707:                     $cls = ImagePeer::getOMClass();
     708:
     709:                     $obj2 = new $cls();
     710:                     $obj2->hydrate($row, $startcol2);
     711:                     ImagePeer::addInstanceToPool($obj2, $key2);
     712:                 } // if obj2 loaded
     713:
     714:                 // Add the $obj1 (ImageI18n) to the collection in $obj2 (Image)
     715:                 $obj2->addImageI18n($obj1);
     716:             } // if joined row not null
     717:
     718:             $results[] = $obj1;
     719:         }
     720:         $stmt->closeCursor();
     721:
     722:         return $results;
     723:     }
     724:
     725:     /**
     726:      * Returns the TableMap related to this peer.
     727:      * This method is not needed for general use but a specific application could have a need.
     728:      * @return TableMap
     729:      * @throws PropelException Any exceptions caught during processing will be
     730:      *       rethrown wrapped into a PropelException.
     731:      */
     732:     public static function getTableMap()
     733:     {
     734:         return Propel::getDatabaseMap(ImageI18nPeer::DATABASE_NAME)->getTable(ImageI18nPeer::TABLE_NAME);
     735:     }
     736:
     737:     /**
     738:      * Add a TableMap instance to the database for this peer class.
     739:      */
     740:     public static function buildTableMap()
     741:     {
     742:       $dbMap = Propel::getDatabaseMap(BaseImageI18nPeer::DATABASE_NAME);
     743:       if (!$dbMap->hasTable(BaseImageI18nPeer::TABLE_NAME)) {
     744:         $dbMap->addTableObject(new ImageI18nTableMap());
     745:       }
     746:     }
     747:
     748:     /**
     749:      * The class that the Peer will make instances of.
     750:      *
     751:      *
     752:      * @return string ClassName
     753:      */
     754:     public static function getOMClass()
     755:     {
     756:         return ImageI18nPeer::OM_CLASS;
     757:     }
     758:
     759:     /**
     760:      * Performs an INSERT on the database, given a ImageI18n or Criteria object.
     761:      *
     762:      * @param      mixed $values Criteria or ImageI18n object containing data that is used to create the INSERT statement.
     763:      * @param      PropelPDO $con the PropelPDO connection to use
     764:      * @return mixed           The new primary key.
     765:      * @throws PropelException Any exceptions caught during processing will be
     766:      *       rethrown wrapped into a PropelException.
     767:      */
     768:     public static function doInsert($values, PropelPDO $con = null)
     769:     {
     770:         if ($con === null) {
     771:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     772:         }
     773:
     774:         if ($values instanceof Criteria) {
     775:             $criteria = clone $values; // rename for clarity
     776:         } else {
     777:             $criteria = $values->buildCriteria(); // build Criteria from ImageI18n object
     778:         }
     779:
     780:
     781:         // Set the correct dbName
     782:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     783:
     784:         try {
     785:             // use transaction because $criteria could contain info
     786:             // for more than one table (I guess, conceivably)
     787:             $con->beginTransaction();
     788:             $pk = BasePeer::doInsert($criteria, $con);
     789:             $con->commit();
     790:         } catch (PropelException $e) {
     791:             $con->rollBack();
     792:             throw $e;
     793:         }
     794:
     795:         return $pk;
     796:     }
     797:
     798:     /**
     799:      * Performs an UPDATE on the database, given a ImageI18n or Criteria object.
     800:      *
     801:      * @param      mixed $values Criteria or ImageI18n object containing data that is used to create the UPDATE statement.
     802:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
     803:      * @return int             The number of affected rows (if supported by underlying database driver).
     804:      * @throws PropelException Any exceptions caught during processing will be
     805:      *       rethrown wrapped into a PropelException.
     806:      */
     807:     public static function doUpdate($values, PropelPDO $con = null)
     808:     {
     809:         if ($con === null) {
     810:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     811:         }
     812:
     813:         $selectCriteria = new Criteria(ImageI18nPeer::DATABASE_NAME);
     814:
     815:         if ($values instanceof Criteria) {
     816:             $criteria = clone $values; // rename for clarity
     817:
     818:             $comparison = $criteria->getComparison(ImageI18nPeer::ID);
     819:             $value = $criteria->remove(ImageI18nPeer::ID);
     820:             if ($value) {
     821:                 $selectCriteria->add(ImageI18nPeer::ID, $value, $comparison);
     822:             } else {
     823:                 $selectCriteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME);
     824:             }
     825:
     826:             $comparison = $criteria->getComparison(ImageI18nPeer::LOCALE);
     827:             $value = $criteria->remove(ImageI18nPeer::LOCALE);
     828:             if ($value) {
     829:                 $selectCriteria->add(ImageI18nPeer::LOCALE, $value, $comparison);
     830:             } else {
     831:                 $selectCriteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME);
     832:             }
     833:
     834:         } else { // $values is ImageI18n object
     835:             $criteria = $values->buildCriteria(); // gets full criteria
     836:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
     837:         }
     838:
     839:         // set the correct dbName
     840:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     841:
     842:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
     843:     }
     844:
     845:     /**
     846:      * Deletes all rows from the image_i18n table.
     847:      *
     848:      * @param      PropelPDO $con the connection to use
     849:      * @return int             The number of affected rows (if supported by underlying database driver).
     850:      * @throws PropelException
     851:      */
     852:     public static function doDeleteAll(PropelPDO $con = null)
     853:     {
     854:         if ($con === null) {
     855:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     856:         }
     857:         $affectedRows = 0; // initialize var to track total num of affected rows
     858:         try {
     859:             // use transaction because $criteria could contain info
     860:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
     861:             $con->beginTransaction();
     862:             $affectedRows += BasePeer::doDeleteAll(ImageI18nPeer::TABLE_NAME, $con, ImageI18nPeer::DATABASE_NAME);
     863:             // Because this db requires some delete cascade/set null emulation, we have to
     864:             // clear the cached instance *after* the emulation has happened (since
     865:             // instances get re-added by the select statement contained therein).
     866:             ImageI18nPeer::clearInstancePool();
     867:             ImageI18nPeer::clearRelatedInstancePool();
     868:             $con->commit();
     869:
     870:             return $affectedRows;
     871:         } catch (PropelException $e) {
     872:             $con->rollBack();
     873:             throw $e;
     874:         }
     875:     }
     876:
     877:     /**
     878:      * Performs a DELETE on the database, given a ImageI18n or Criteria object OR a primary key value.
     879:      *
     880:      * @param      mixed $values Criteria or ImageI18n object or primary key or array of primary keys
     881:      *              which is used to create the DELETE statement
     882:      * @param      PropelPDO $con the connection to use
     883:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
     884:      *              if supported by native driver or if emulated using Propel.
     885:      * @throws PropelException Any exceptions caught during processing will be
     886:      *       rethrown wrapped into a PropelException.
     887:      */
     888:      public static function doDelete($values, PropelPDO $con = null)
     889:      {
     890:         if ($con === null) {
     891:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     892:         }
     893:
     894:         if ($values instanceof Criteria) {
     895:             // invalidate the cache for all objects of this type, since we have no
     896:             // way of knowing (without running a query) what objects should be invalidated
     897:             // from the cache based on this Criteria.
     898:             ImageI18nPeer::clearInstancePool();
     899:             // rename for clarity
     900:             $criteria = clone $values;
     901:         } elseif ($values instanceof ImageI18n) { // it's a model object
     902:             // invalidate the cache for this single object
     903:             ImageI18nPeer::removeInstanceFromPool($values);
     904:             // create criteria based on pk values
     905:             $criteria = $values->buildPkeyCriteria();
     906:         } else { // it's a primary key, or an array of pks
     907:             $criteria = new Criteria(ImageI18nPeer::DATABASE_NAME);
     908:             // primary key is composite; we therefore, expect
     909:             // the primary key passed to be an array of pkey values
     910:             if (count($values) == count($values, COUNT_RECURSIVE)) {
     911:                 // array is not multi-dimensional
     912:                 $values = array($values);
     913:             }
     914:             foreach ($values as $value) {
     915:                 $criterion = $criteria->getNewCriterion(ImageI18nPeer::ID, $value[0]);
     916:                 $criterion->addAnd($criteria->getNewCriterion(ImageI18nPeer::LOCALE, $value[1]));
     917:                 $criteria->addOr($criterion);
     918:                 // we can invalidate the cache for this single PK
     919:                 ImageI18nPeer::removeInstanceFromPool($value);
     920:             }
     921:         }
     922:
     923:         // Set the correct dbName
     924:         $criteria->setDbName(ImageI18nPeer::DATABASE_NAME);
     925:
     926:         $affectedRows = 0; // initialize var to track total num of affected rows
     927:
     928:         try {
     929:             // use transaction because $criteria could contain info
     930:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
     931:             $con->beginTransaction();
     932:
     933:             $affectedRows += BasePeer::doDelete($criteria, $con);
     934:             ImageI18nPeer::clearRelatedInstancePool();
     935:             $con->commit();
     936:
     937:             return $affectedRows;
     938:         } catch (PropelException $e) {
     939:             $con->rollBack();
     940:             throw $e;
     941:         }
     942:     }
     943:
     944:     /**
     945:      * Validates all modified columns of given ImageI18n object.
     946:      * If parameter $columns is either a single column name or an array of column names
     947:      * than only those columns are validated.
     948:      *
     949:      * NOTICE: This does not apply to primary or foreign keys for now.
     950:      *
     951:      * @param      ImageI18n $obj The object to validate.
     952:      * @param      mixed $cols Column name or array of column names.
     953:      *
     954:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
     955:      */
     956:     public static function doValidate($obj, $cols = null)
     957:     {
     958:         $columns = array();
     959:
     960:         if ($cols) {
     961:             $dbMap = Propel::getDatabaseMap(ImageI18nPeer::DATABASE_NAME);
     962:             $tableMap = $dbMap->getTable(ImageI18nPeer::TABLE_NAME);
     963:
     964:             if (! is_array($cols)) {
     965:                 $cols = array($cols);
     966:             }
     967:
     968:             foreach ($cols as $colName) {
     969:                 if ($tableMap->hasColumn($colName)) {
     970:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
     971:                     $columns[$colName] = $obj->$get();
     972:                 }
     973:             }
     974:         } else {
     975:
     976:         }
     977:
     978:         return BasePeer::doValidate(ImageI18nPeer::DATABASE_NAME, ImageI18nPeer::TABLE_NAME, $columns);
     979:     }
     980:
     981:     /**
     982:      * Retrieve object using using composite pkey values.
     983:      * @param   int $id
     984:      * @param   string $locale
     985:      * @param      PropelPDO $con
     986:      * @return   ImageI18n
     987:      */
     988:     public static function retrieveByPK($id, $locale, PropelPDO $con = null) {
     989:         $_instancePoolKey = serialize(array((string) $id, (string) $locale));
     990:          if (null !== ($obj = ImageI18nPeer::getInstanceFromPool($_instancePoolKey))) {
     991:              return $obj;
     992:         }
     993:
     994:         if ($con === null) {
     995:             $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     996:         }
     997:         $criteria = new Criteria(ImageI18nPeer::DATABASE_NAME);
     998:         $criteria->add(ImageI18nPeer::ID, $id);
     999:         $criteria->add(ImageI18nPeer::LOCALE, $locale);
    1000:         $v = ImageI18nPeer::doSelect($criteria, $con);
    1001:
    1002:         return !empty($v) ? $v[0] : null;
    1003:     }
    1004: } // BaseImageI18nPeer
    1005:
    1006: // This is the static code needed to register the TableMap for this table with the main Propel class.
    1007: //
    1008: BaseImageI18nPeer::buildTableMap();
    1009:
    1010: