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