Overview

Namespaces

  • Thelia
    • Action
    • Config
    • Controller
    • Core
      • Bundle
      • DependencyInjection
        • Compiler
        • Loader
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Element
        • Loop
        • TestLoop
      • Event
      • Exception
      • Filter
      • Tokenizer

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModule
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseModuleQuery
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleI18n
  • BaseTaxRuleI18nPeer
  • BaseTaxRuleI18nQuery
  • BaseTaxRulePeer
  • BaseTaxRuleQuery
  • Overview
  • Namespace
  • Class
  • Tree
   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\Accessory;
  13: use Thelia\Model\AccessoryPeer;
  14: use Thelia\Model\ProductPeer;
  15: use Thelia\Model\map\AccessoryTableMap;
  16: 
  17: /**
  18:  * Base static class for performing query and update operations on the 'accessory' table.
  19:  *
  20:  *
  21:  *
  22:  * @package propel.generator.Thelia.Model.om
  23:  */
  24: abstract class BaseAccessoryPeer
  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 = 'accessory';
  32: 
  33:     /** the related Propel class for this table */
  34:     const OM_CLASS = 'Thelia\\Model\\Accessory';
  35: 
  36:     /** the related TableMap class for this table */
  37:     const TM_CLASS = 'AccessoryTableMap';
  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 = 'accessory.id';
  50: 
  51:     /** the column name for the product_id field */
  52:     const PRODUCT_ID = 'accessory.product_id';
  53: 
  54:     /** the column name for the accessory field */
  55:     const ACCESSORY = 'accessory.accessory';
  56: 
  57:     /** the column name for the position field */
  58:     const POSITION = 'accessory.position';
  59: 
  60:     /** the column name for the created_at field */
  61:     const CREATED_AT = 'accessory.created_at';
  62: 
  63:     /** the column name for the updated_at field */
  64:     const UPDATED_AT = 'accessory.updated_at';
  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 Accessory objects.
  71:      * This must be public so that other peer classes can access this when hydrating from JOIN
  72:      * queries.
  73:      * @var        array Accessory[]
  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. AccessoryPeer::$fieldNames[AccessoryPeer::TYPE_PHPNAME][0] = 'Id'
  83:      */
  84:     protected static $fieldNames = array (
  85:         BasePeer::TYPE_PHPNAME => array ('Id', 'ProductId', 'Accessory', 'Position', 'CreatedAt', 'UpdatedAt', ),
  86:         BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'accessory', 'position', 'createdAt', 'updatedAt', ),
  87:         BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID, AccessoryPeer::PRODUCT_ID, AccessoryPeer::ACCESSORY, AccessoryPeer::POSITION, AccessoryPeer::CREATED_AT, AccessoryPeer::UPDATED_AT, ),
  88:         BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'ACCESSORY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
  89:         BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'accessory', 'position', 'created_at', 'updated_at', ),
  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. AccessoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
  98:      */
  99:     protected static $fieldKeys = array (
 100:         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Accessory' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
 101:         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'accessory' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
 102:         BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID => 0, AccessoryPeer::PRODUCT_ID => 1, AccessoryPeer::ACCESSORY => 2, AccessoryPeer::POSITION => 3, AccessoryPeer::CREATED_AT => 4, AccessoryPeer::UPDATED_AT => 5, ),
 103:         BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'ACCESSORY' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
 104:         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'accessory' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 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 = AccessoryPeer::getFieldNames($toType);
 121:         $key = isset(AccessoryPeer::$fieldKeys[$fromType][$name]) ? AccessoryPeer::$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(AccessoryPeer::$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, AccessoryPeer::$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 AccessoryPeer::$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. AccessoryPeer::COLUMN_NAME).
 157:      * @return string
 158:      */
 159:     public static function alias($alias, $column)
 160:     {
 161:         return str_replace(AccessoryPeer::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(AccessoryPeer::ID);
 180:             $criteria->addSelectColumn(AccessoryPeer::PRODUCT_ID);
 181:             $criteria->addSelectColumn(AccessoryPeer::ACCESSORY);
 182:             $criteria->addSelectColumn(AccessoryPeer::POSITION);
 183:             $criteria->addSelectColumn(AccessoryPeer::CREATED_AT);
 184:             $criteria->addSelectColumn(AccessoryPeer::UPDATED_AT);
 185:         } else {
 186:             $criteria->addSelectColumn($alias . '.id');
 187:             $criteria->addSelectColumn($alias . '.product_id');
 188:             $criteria->addSelectColumn($alias . '.accessory');
 189:             $criteria->addSelectColumn($alias . '.position');
 190:             $criteria->addSelectColumn($alias . '.created_at');
 191:             $criteria->addSelectColumn($alias . '.updated_at');
 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(AccessoryPeer::TABLE_NAME);
 212: 
 213:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 214:             $criteria->setDistinct();
 215:         }
 216: 
 217:         if (!$criteria->hasSelectClause()) {
 218:             AccessoryPeer::addSelectColumns($criteria);
 219:         }
 220: 
 221:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
 222:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME); // Set the correct dbName
 223: 
 224:         if ($con === null) {
 225:             $con = Propel::getConnection(AccessoryPeer::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                 Accessory
 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 = AccessoryPeer::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 AccessoryPeer::populateObjects(AccessoryPeer::doSelectStmt($criteria, $con));
 271:     }
 272:     /**
 273:      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
 274:      *
 275:      * Use this method directly if you want to work with an executed statement directly (for example
 276:      * to perform your own object hydration).
 277:      *
 278:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
 279:      * @param      PropelPDO $con The connection to use
 280:      * @throws PropelException Any exceptions caught during processing will be
 281:      *       rethrown wrapped into a PropelException.
 282:      * @return PDOStatement The executed PDOStatement object.
 283:      * @see        BasePeer::doSelect()
 284:      */
 285:     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
 286:     {
 287:         if ($con === null) {
 288:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 289:         }
 290: 
 291:         if (!$criteria->hasSelectClause()) {
 292:             $criteria = clone $criteria;
 293:             AccessoryPeer::addSelectColumns($criteria);
 294:         }
 295: 
 296:         // Set the correct dbName
 297:         $criteria->setDbName(AccessoryPeer::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      Accessory $obj A Accessory 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 = (string) $obj->getId();
 319:             } // if key === null
 320:             AccessoryPeer::$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 Accessory 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 Accessory) {
 341:                 $key = (string) $value->getId();
 342:             } elseif (is_scalar($value)) {
 343:                 // assume we've been passed a primary key
 344:                 $key = (string) $value;
 345:             } else {
 346:                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Accessory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
 347:                 throw $e;
 348:             }
 349: 
 350:             unset(AccessoryPeer::$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   Accessory 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(AccessoryPeer::$instances[$key])) {
 368:                 return AccessoryPeer::$instances[$key];
 369:             }
 370:         }
 371: 
 372:         return null; // just to be explicit
 373:     }
 374: 
 375:     /**
 376:      * Clear the instance pool.
 377:      *
 378:      * @return void
 379:      */
 380:     public static function clearInstancePool($and_clear_all_references = false)
 381:     {
 382:       if ($and_clear_all_references)
 383:       {
 384:         foreach (AccessoryPeer::$instances as $instance)
 385:         {
 386:           $instance->clearAllReferences(true);
 387:         }
 388:       }
 389:         AccessoryPeer::$instances = array();
 390:     }
 391: 
 392:     /**
 393:      * Method to invalidate the instance pool of all tables related to accessory
 394:      * by a foreign key with ON DELETE CASCADE
 395:      */
 396:     public static function clearRelatedInstancePool()
 397:     {
 398:     }
 399: 
 400:     /**
 401:      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
 402:      *
 403:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
 404:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
 405:      *
 406:      * @param      array $row PropelPDO resultset row.
 407:      * @param      int $startcol The 0-based offset for reading from the resultset row.
 408:      * @return string A string version of PK or null if the components of primary key in result array are all null.
 409:      */
 410:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
 411:     {
 412:         // If the PK cannot be derived from the row, return null.
 413:         if ($row[$startcol] === null) {
 414:             return null;
 415:         }
 416: 
 417:         return (string) $row[$startcol];
 418:     }
 419: 
 420:     /**
 421:      * Retrieves the primary key from the DB resultset row
 422:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
 423:      * a multi-column primary key, an array of the primary key columns will be returned.
 424:      *
 425:      * @param      array $row PropelPDO resultset row.
 426:      * @param      int $startcol The 0-based offset for reading from the resultset row.
 427:      * @return mixed The primary key of the row
 428:      */
 429:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
 430:     {
 431: 
 432:         return (int) $row[$startcol];
 433:     }
 434: 
 435:     /**
 436:      * The returned array will contain objects of the default type or
 437:      * objects that inherit from the default.
 438:      *
 439:      * @throws PropelException Any exceptions caught during processing will be
 440:      *       rethrown wrapped into a PropelException.
 441:      */
 442:     public static function populateObjects(PDOStatement $stmt)
 443:     {
 444:         $results = array();
 445: 
 446:         // set the class once to avoid overhead in the loop
 447:         $cls = AccessoryPeer::getOMClass();
 448:         // populate the object(s)
 449:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 450:             $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
 451:             if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) {
 452:                 // We no longer rehydrate the object, since this can cause data loss.
 453:                 // See http://www.propelorm.org/ticket/509
 454:                 // $obj->hydrate($row, 0, true); // rehydrate
 455:                 $results[] = $obj;
 456:             } else {
 457:                 $obj = new $cls();
 458:                 $obj->hydrate($row);
 459:                 $results[] = $obj;
 460:                 AccessoryPeer::addInstanceToPool($obj, $key);
 461:             } // if key exists
 462:         }
 463:         $stmt->closeCursor();
 464: 
 465:         return $results;
 466:     }
 467:     /**
 468:      * Populates an object of the default type or an object that inherit from the default.
 469:      *
 470:      * @param      array $row PropelPDO resultset row.
 471:      * @param      int $startcol The 0-based offset for reading from the resultset row.
 472:      * @throws PropelException Any exceptions caught during processing will be
 473:      *       rethrown wrapped into a PropelException.
 474:      * @return array (Accessory object, last column rank)
 475:      */
 476:     public static function populateObject($row, $startcol = 0)
 477:     {
 478:         $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
 479:         if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) {
 480:             // We no longer rehydrate the object, since this can cause data loss.
 481:             // See http://www.propelorm.org/ticket/509
 482:             // $obj->hydrate($row, $startcol, true); // rehydrate
 483:             $col = $startcol + AccessoryPeer::NUM_HYDRATE_COLUMNS;
 484:         } else {
 485:             $cls = AccessoryPeer::OM_CLASS;
 486:             $obj = new $cls();
 487:             $col = $obj->hydrate($row, $startcol);
 488:             AccessoryPeer::addInstanceToPool($obj, $key);
 489:         }
 490: 
 491:         return array($obj, $col);
 492:     }
 493: 
 494: 
 495:     /**
 496:      * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table
 497:      *
 498:      * @param      Criteria $criteria
 499:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
 500:      * @param      PropelPDO $con
 501:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 502:      * @return int Number of matching rows.
 503:      */
 504:     public static function doCountJoinProductRelatedByProductId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
 505:     {
 506:         // we're going to modify criteria, so copy it first
 507:         $criteria = clone $criteria;
 508: 
 509:         // We need to set the primary table name, since in the case that there are no WHERE columns
 510:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
 511:         // tables go into the FROM clause.
 512:         $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
 513: 
 514:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 515:             $criteria->setDistinct();
 516:         }
 517: 
 518:         if (!$criteria->hasSelectClause()) {
 519:             AccessoryPeer::addSelectColumns($criteria);
 520:         }
 521: 
 522:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
 523: 
 524:         // Set the correct dbName
 525:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 526: 
 527:         if ($con === null) {
 528:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 529:         }
 530: 
 531:         $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
 532: 
 533:         $stmt = BasePeer::doCount($criteria, $con);
 534: 
 535:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 536:             $count = (int) $row[0];
 537:         } else {
 538:             $count = 0; // no rows returned; we infer that means 0 matches.
 539:         }
 540:         $stmt->closeCursor();
 541: 
 542:         return $count;
 543:     }
 544: 
 545: 
 546:     /**
 547:      * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table
 548:      *
 549:      * @param      Criteria $criteria
 550:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
 551:      * @param      PropelPDO $con
 552:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 553:      * @return int Number of matching rows.
 554:      */
 555:     public static function doCountJoinProductRelatedByAccessory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
 556:     {
 557:         // we're going to modify criteria, so copy it first
 558:         $criteria = clone $criteria;
 559: 
 560:         // We need to set the primary table name, since in the case that there are no WHERE columns
 561:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
 562:         // tables go into the FROM clause.
 563:         $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
 564: 
 565:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 566:             $criteria->setDistinct();
 567:         }
 568: 
 569:         if (!$criteria->hasSelectClause()) {
 570:             AccessoryPeer::addSelectColumns($criteria);
 571:         }
 572: 
 573:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
 574: 
 575:         // Set the correct dbName
 576:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 577: 
 578:         if ($con === null) {
 579:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 580:         }
 581: 
 582:         $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
 583: 
 584:         $stmt = BasePeer::doCount($criteria, $con);
 585: 
 586:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 587:             $count = (int) $row[0];
 588:         } else {
 589:             $count = 0; // no rows returned; we infer that means 0 matches.
 590:         }
 591:         $stmt->closeCursor();
 592: 
 593:         return $count;
 594:     }
 595: 
 596: 
 597:     /**
 598:      * Selects a collection of Accessory objects pre-filled with their Product objects.
 599:      * @param      Criteria  $criteria
 600:      * @param      PropelPDO $con
 601:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 602:      * @return array           Array of Accessory objects.
 603:      * @throws PropelException Any exceptions caught during processing will be
 604:      *       rethrown wrapped into a PropelException.
 605:      */
 606:     public static function doSelectJoinProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 607:     {
 608:         $criteria = clone $criteria;
 609: 
 610:         // Set the correct dbName if it has not been overridden
 611:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
 612:             $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 613:         }
 614: 
 615:         AccessoryPeer::addSelectColumns($criteria);
 616:         $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS;
 617:         ProductPeer::addSelectColumns($criteria);
 618: 
 619:         $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
 620: 
 621:         $stmt = BasePeer::doSelect($criteria, $con);
 622:         $results = array();
 623: 
 624:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 625:             $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
 626:             if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
 627:                 // We no longer rehydrate the object, since this can cause data loss.
 628:                 // See http://www.propelorm.org/ticket/509
 629:                 // $obj1->hydrate($row, 0, true); // rehydrate
 630:             } else {
 631: 
 632:                 $cls = AccessoryPeer::getOMClass();
 633: 
 634:                 $obj1 = new $cls();
 635:                 $obj1->hydrate($row);
 636:                 AccessoryPeer::addInstanceToPool($obj1, $key1);
 637:             } // if $obj1 already loaded
 638: 
 639:             $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
 640:             if ($key2 !== null) {
 641:                 $obj2 = ProductPeer::getInstanceFromPool($key2);
 642:                 if (!$obj2) {
 643: 
 644:                     $cls = ProductPeer::getOMClass();
 645: 
 646:                     $obj2 = new $cls();
 647:                     $obj2->hydrate($row, $startcol);
 648:                     ProductPeer::addInstanceToPool($obj2, $key2);
 649:                 } // if obj2 already loaded
 650: 
 651:                 // Add the $obj1 (Accessory) to $obj2 (Product)
 652:                 $obj2->addAccessoryRelatedByProductId($obj1);
 653: 
 654:             } // if joined row was not null
 655: 
 656:             $results[] = $obj1;
 657:         }
 658:         $stmt->closeCursor();
 659: 
 660:         return $results;
 661:     }
 662: 
 663: 
 664:     /**
 665:      * Selects a collection of Accessory objects pre-filled with their Product objects.
 666:      * @param      Criteria  $criteria
 667:      * @param      PropelPDO $con
 668:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 669:      * @return array           Array of Accessory objects.
 670:      * @throws PropelException Any exceptions caught during processing will be
 671:      *       rethrown wrapped into a PropelException.
 672:      */
 673:     public static function doSelectJoinProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 674:     {
 675:         $criteria = clone $criteria;
 676: 
 677:         // Set the correct dbName if it has not been overridden
 678:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
 679:             $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 680:         }
 681: 
 682:         AccessoryPeer::addSelectColumns($criteria);
 683:         $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS;
 684:         ProductPeer::addSelectColumns($criteria);
 685: 
 686:         $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
 687: 
 688:         $stmt = BasePeer::doSelect($criteria, $con);
 689:         $results = array();
 690: 
 691:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 692:             $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
 693:             if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
 694:                 // We no longer rehydrate the object, since this can cause data loss.
 695:                 // See http://www.propelorm.org/ticket/509
 696:                 // $obj1->hydrate($row, 0, true); // rehydrate
 697:             } else {
 698: 
 699:                 $cls = AccessoryPeer::getOMClass();
 700: 
 701:                 $obj1 = new $cls();
 702:                 $obj1->hydrate($row);
 703:                 AccessoryPeer::addInstanceToPool($obj1, $key1);
 704:             } // if $obj1 already loaded
 705: 
 706:             $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
 707:             if ($key2 !== null) {
 708:                 $obj2 = ProductPeer::getInstanceFromPool($key2);
 709:                 if (!$obj2) {
 710: 
 711:                     $cls = ProductPeer::getOMClass();
 712: 
 713:                     $obj2 = new $cls();
 714:                     $obj2->hydrate($row, $startcol);
 715:                     ProductPeer::addInstanceToPool($obj2, $key2);
 716:                 } // if obj2 already loaded
 717: 
 718:                 // Add the $obj1 (Accessory) to $obj2 (Product)
 719:                 $obj2->addAccessoryRelatedByAccessory($obj1);
 720: 
 721:             } // if joined row was not null
 722: 
 723:             $results[] = $obj1;
 724:         }
 725:         $stmt->closeCursor();
 726: 
 727:         return $results;
 728:     }
 729: 
 730: 
 731:     /**
 732:      * Returns the number of rows matching criteria, joining all related tables
 733:      *
 734:      * @param      Criteria $criteria
 735:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
 736:      * @param      PropelPDO $con
 737:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 738:      * @return int Number of matching rows.
 739:      */
 740:     public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
 741:     {
 742:         // we're going to modify criteria, so copy it first
 743:         $criteria = clone $criteria;
 744: 
 745:         // We need to set the primary table name, since in the case that there are no WHERE columns
 746:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
 747:         // tables go into the FROM clause.
 748:         $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
 749: 
 750:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 751:             $criteria->setDistinct();
 752:         }
 753: 
 754:         if (!$criteria->hasSelectClause()) {
 755:             AccessoryPeer::addSelectColumns($criteria);
 756:         }
 757: 
 758:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
 759: 
 760:         // Set the correct dbName
 761:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 762: 
 763:         if ($con === null) {
 764:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 765:         }
 766: 
 767:         $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
 768: 
 769:         $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
 770: 
 771:         $stmt = BasePeer::doCount($criteria, $con);
 772: 
 773:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 774:             $count = (int) $row[0];
 775:         } else {
 776:             $count = 0; // no rows returned; we infer that means 0 matches.
 777:         }
 778:         $stmt->closeCursor();
 779: 
 780:         return $count;
 781:     }
 782: 
 783:     /**
 784:      * Selects a collection of Accessory objects pre-filled with all related objects.
 785:      *
 786:      * @param      Criteria  $criteria
 787:      * @param      PropelPDO $con
 788:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 789:      * @return array           Array of Accessory objects.
 790:      * @throws PropelException Any exceptions caught during processing will be
 791:      *       rethrown wrapped into a PropelException.
 792:      */
 793:     public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 794:     {
 795:         $criteria = clone $criteria;
 796: 
 797:         // Set the correct dbName if it has not been overridden
 798:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
 799:             $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 800:         }
 801: 
 802:         AccessoryPeer::addSelectColumns($criteria);
 803:         $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
 804: 
 805:         ProductPeer::addSelectColumns($criteria);
 806:         $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
 807: 
 808:         ProductPeer::addSelectColumns($criteria);
 809:         $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
 810: 
 811:         $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
 812: 
 813:         $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior);
 814: 
 815:         $stmt = BasePeer::doSelect($criteria, $con);
 816:         $results = array();
 817: 
 818:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 819:             $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
 820:             if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
 821:                 // We no longer rehydrate the object, since this can cause data loss.
 822:                 // See http://www.propelorm.org/ticket/509
 823:                 // $obj1->hydrate($row, 0, true); // rehydrate
 824:             } else {
 825:                 $cls = AccessoryPeer::getOMClass();
 826: 
 827:                 $obj1 = new $cls();
 828:                 $obj1->hydrate($row);
 829:                 AccessoryPeer::addInstanceToPool($obj1, $key1);
 830:             } // if obj1 already loaded
 831: 
 832:             // Add objects for joined Product rows
 833: 
 834:             $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
 835:             if ($key2 !== null) {
 836:                 $obj2 = ProductPeer::getInstanceFromPool($key2);
 837:                 if (!$obj2) {
 838: 
 839:                     $cls = ProductPeer::getOMClass();
 840: 
 841:                     $obj2 = new $cls();
 842:                     $obj2->hydrate($row, $startcol2);
 843:                     ProductPeer::addInstanceToPool($obj2, $key2);
 844:                 } // if obj2 loaded
 845: 
 846:                 // Add the $obj1 (Accessory) to the collection in $obj2 (Product)
 847:                 $obj2->addAccessoryRelatedByProductId($obj1);
 848:             } // if joined row not null
 849: 
 850:             // Add objects for joined Product rows
 851: 
 852:             $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
 853:             if ($key3 !== null) {
 854:                 $obj3 = ProductPeer::getInstanceFromPool($key3);
 855:                 if (!$obj3) {
 856: 
 857:                     $cls = ProductPeer::getOMClass();
 858: 
 859:                     $obj3 = new $cls();
 860:                     $obj3->hydrate($row, $startcol3);
 861:                     ProductPeer::addInstanceToPool($obj3, $key3);
 862:                 } // if obj3 loaded
 863: 
 864:                 // Add the $obj1 (Accessory) to the collection in $obj3 (Product)
 865:                 $obj3->addAccessoryRelatedByAccessory($obj1);
 866:             } // if joined row not null
 867: 
 868:             $results[] = $obj1;
 869:         }
 870:         $stmt->closeCursor();
 871: 
 872:         return $results;
 873:     }
 874: 
 875: 
 876:     /**
 877:      * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table
 878:      *
 879:      * @param      Criteria $criteria
 880:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
 881:      * @param      PropelPDO $con
 882:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 883:      * @return int Number of matching rows.
 884:      */
 885:     public static function doCountJoinAllExceptProductRelatedByProductId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
 886:     {
 887:         // we're going to modify criteria, so copy it first
 888:         $criteria = clone $criteria;
 889: 
 890:         // We need to set the primary table name, since in the case that there are no WHERE columns
 891:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
 892:         // tables go into the FROM clause.
 893:         $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
 894: 
 895:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 896:             $criteria->setDistinct();
 897:         }
 898: 
 899:         if (!$criteria->hasSelectClause()) {
 900:             AccessoryPeer::addSelectColumns($criteria);
 901:         }
 902: 
 903:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
 904: 
 905:         // Set the correct dbName
 906:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 907: 
 908:         if ($con === null) {
 909:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 910:         }
 911: 
 912:         $stmt = BasePeer::doCount($criteria, $con);
 913: 
 914:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 915:             $count = (int) $row[0];
 916:         } else {
 917:             $count = 0; // no rows returned; we infer that means 0 matches.
 918:         }
 919:         $stmt->closeCursor();
 920: 
 921:         return $count;
 922:     }
 923: 
 924: 
 925:     /**
 926:      * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table
 927:      *
 928:      * @param      Criteria $criteria
 929:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
 930:      * @param      PropelPDO $con
 931:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 932:      * @return int Number of matching rows.
 933:      */
 934:     public static function doCountJoinAllExceptProductRelatedByAccessory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
 935:     {
 936:         // we're going to modify criteria, so copy it first
 937:         $criteria = clone $criteria;
 938: 
 939:         // We need to set the primary table name, since in the case that there are no WHERE columns
 940:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
 941:         // tables go into the FROM clause.
 942:         $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
 943: 
 944:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
 945:             $criteria->setDistinct();
 946:         }
 947: 
 948:         if (!$criteria->hasSelectClause()) {
 949:             AccessoryPeer::addSelectColumns($criteria);
 950:         }
 951: 
 952:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
 953: 
 954:         // Set the correct dbName
 955:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 956: 
 957:         if ($con === null) {
 958:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 959:         }
 960: 
 961:         $stmt = BasePeer::doCount($criteria, $con);
 962: 
 963:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
 964:             $count = (int) $row[0];
 965:         } else {
 966:             $count = 0; // no rows returned; we infer that means 0 matches.
 967:         }
 968:         $stmt->closeCursor();
 969: 
 970:         return $count;
 971:     }
 972: 
 973: 
 974:     /**
 975:      * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByProductId.
 976:      *
 977:      * @param      Criteria  $criteria
 978:      * @param      PropelPDO $con
 979:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
 980:      * @return array           Array of Accessory objects.
 981:      * @throws PropelException Any exceptions caught during processing will be
 982:      *       rethrown wrapped into a PropelException.
 983:      */
 984:     public static function doSelectJoinAllExceptProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 985:     {
 986:         $criteria = clone $criteria;
 987: 
 988:         // Set the correct dbName if it has not been overridden
 989:         // $criteria->getDbName() will return the same object if not set to another value
 990:         // so == check is okay and faster
 991:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
 992:             $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
 993:         }
 994: 
 995:         AccessoryPeer::addSelectColumns($criteria);
 996:         $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
 997: 
 998: 
 999:         $stmt = BasePeer::doSelect($criteria, $con);
1000:         $results = array();
1001: 
1002:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1003:             $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
1004:             if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
1005:                 // We no longer rehydrate the object, since this can cause data loss.
1006:                 // See http://www.propelorm.org/ticket/509
1007:                 // $obj1->hydrate($row, 0, true); // rehydrate
1008:             } else {
1009:                 $cls = AccessoryPeer::getOMClass();
1010: 
1011:                 $obj1 = new $cls();
1012:                 $obj1->hydrate($row);
1013:                 AccessoryPeer::addInstanceToPool($obj1, $key1);
1014:             } // if obj1 already loaded
1015: 
1016:             $results[] = $obj1;
1017:         }
1018:         $stmt->closeCursor();
1019: 
1020:         return $results;
1021:     }
1022: 
1023: 
1024:     /**
1025:      * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByAccessory.
1026:      *
1027:      * @param      Criteria  $criteria
1028:      * @param      PropelPDO $con
1029:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
1030:      * @return array           Array of Accessory objects.
1031:      * @throws PropelException Any exceptions caught during processing will be
1032:      *       rethrown wrapped into a PropelException.
1033:      */
1034:     public static function doSelectJoinAllExceptProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1035:     {
1036:         $criteria = clone $criteria;
1037: 
1038:         // Set the correct dbName if it has not been overridden
1039:         // $criteria->getDbName() will return the same object if not set to another value
1040:         // so == check is okay and faster
1041:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
1042:             $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
1043:         }
1044: 
1045:         AccessoryPeer::addSelectColumns($criteria);
1046:         $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS;
1047: 
1048: 
1049:         $stmt = BasePeer::doSelect($criteria, $con);
1050:         $results = array();
1051: 
1052:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1053:             $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0);
1054:             if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) {
1055:                 // We no longer rehydrate the object, since this can cause data loss.
1056:                 // See http://www.propelorm.org/ticket/509
1057:                 // $obj1->hydrate($row, 0, true); // rehydrate
1058:             } else {
1059:                 $cls = AccessoryPeer::getOMClass();
1060: 
1061:                 $obj1 = new $cls();
1062:                 $obj1->hydrate($row);
1063:                 AccessoryPeer::addInstanceToPool($obj1, $key1);
1064:             } // if obj1 already loaded
1065: 
1066:             $results[] = $obj1;
1067:         }
1068:         $stmt->closeCursor();
1069: 
1070:         return $results;
1071:     }
1072: 
1073:     /**
1074:      * Returns the TableMap related to this peer.
1075:      * This method is not needed for general use but a specific application could have a need.
1076:      * @return TableMap
1077:      * @throws PropelException Any exceptions caught during processing will be
1078:      *       rethrown wrapped into a PropelException.
1079:      */
1080:     public static function getTableMap()
1081:     {
1082:         return Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME)->getTable(AccessoryPeer::TABLE_NAME);
1083:     }
1084: 
1085:     /**
1086:      * Add a TableMap instance to the database for this peer class.
1087:      */
1088:     public static function buildTableMap()
1089:     {
1090:       $dbMap = Propel::getDatabaseMap(BaseAccessoryPeer::DATABASE_NAME);
1091:       if (!$dbMap->hasTable(BaseAccessoryPeer::TABLE_NAME)) {
1092:         $dbMap->addTableObject(new AccessoryTableMap());
1093:       }
1094:     }
1095: 
1096:     /**
1097:      * The class that the Peer will make instances of.
1098:      *
1099:      *
1100:      * @return string ClassName
1101:      */
1102:     public static function getOMClass($row = 0, $colnum = 0)
1103:     {
1104:         return AccessoryPeer::OM_CLASS;
1105:     }
1106: 
1107:     /**
1108:      * Performs an INSERT on the database, given a Accessory or Criteria object.
1109:      *
1110:      * @param      mixed $values Criteria or Accessory object containing data that is used to create the INSERT statement.
1111:      * @param      PropelPDO $con the PropelPDO connection to use
1112:      * @return mixed           The new primary key.
1113:      * @throws PropelException Any exceptions caught during processing will be
1114:      *       rethrown wrapped into a PropelException.
1115:      */
1116:     public static function doInsert($values, PropelPDO $con = null)
1117:     {
1118:         if ($con === null) {
1119:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1120:         }
1121: 
1122:         if ($values instanceof Criteria) {
1123:             $criteria = clone $values; // rename for clarity
1124:         } else {
1125:             $criteria = $values->buildCriteria(); // build Criteria from Accessory object
1126:         }
1127: 
1128: 
1129:         // Set the correct dbName
1130:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
1131: 
1132:         try {
1133:             // use transaction because $criteria could contain info
1134:             // for more than one table (I guess, conceivably)
1135:             $con->beginTransaction();
1136:             $pk = BasePeer::doInsert($criteria, $con);
1137:             $con->commit();
1138:         } catch (PropelException $e) {
1139:             $con->rollBack();
1140:             throw $e;
1141:         }
1142: 
1143:         return $pk;
1144:     }
1145: 
1146:     /**
1147:      * Performs an UPDATE on the database, given a Accessory or Criteria object.
1148:      *
1149:      * @param      mixed $values Criteria or Accessory object containing data that is used to create the UPDATE statement.
1150:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
1151:      * @return int             The number of affected rows (if supported by underlying database driver).
1152:      * @throws PropelException Any exceptions caught during processing will be
1153:      *       rethrown wrapped into a PropelException.
1154:      */
1155:     public static function doUpdate($values, PropelPDO $con = null)
1156:     {
1157:         if ($con === null) {
1158:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1159:         }
1160: 
1161:         $selectCriteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1162: 
1163:         if ($values instanceof Criteria) {
1164:             $criteria = clone $values; // rename for clarity
1165: 
1166:             $comparison = $criteria->getComparison(AccessoryPeer::ID);
1167:             $value = $criteria->remove(AccessoryPeer::ID);
1168:             if ($value) {
1169:                 $selectCriteria->add(AccessoryPeer::ID, $value, $comparison);
1170:             } else {
1171:                 $selectCriteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME);
1172:             }
1173: 
1174:         } else { // $values is Accessory object
1175:             $criteria = $values->buildCriteria(); // gets full criteria
1176:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
1177:         }
1178: 
1179:         // set the correct dbName
1180:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
1181: 
1182:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
1183:     }
1184: 
1185:     /**
1186:      * Deletes all rows from the accessory table.
1187:      *
1188:      * @param      PropelPDO $con the connection to use
1189:      * @return int             The number of affected rows (if supported by underlying database driver).
1190:      * @throws PropelException
1191:      */
1192:     public static function doDeleteAll(PropelPDO $con = null)
1193:     {
1194:         if ($con === null) {
1195:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1196:         }
1197:         $affectedRows = 0; // initialize var to track total num of affected rows
1198:         try {
1199:             // use transaction because $criteria could contain info
1200:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
1201:             $con->beginTransaction();
1202:             $affectedRows += BasePeer::doDeleteAll(AccessoryPeer::TABLE_NAME, $con, AccessoryPeer::DATABASE_NAME);
1203:             // Because this db requires some delete cascade/set null emulation, we have to
1204:             // clear the cached instance *after* the emulation has happened (since
1205:             // instances get re-added by the select statement contained therein).
1206:             AccessoryPeer::clearInstancePool();
1207:             AccessoryPeer::clearRelatedInstancePool();
1208:             $con->commit();
1209: 
1210:             return $affectedRows;
1211:         } catch (PropelException $e) {
1212:             $con->rollBack();
1213:             throw $e;
1214:         }
1215:     }
1216: 
1217:     /**
1218:      * Performs a DELETE on the database, given a Accessory or Criteria object OR a primary key value.
1219:      *
1220:      * @param      mixed $values Criteria or Accessory object or primary key or array of primary keys
1221:      *              which is used to create the DELETE statement
1222:      * @param      PropelPDO $con the connection to use
1223:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
1224:      *              if supported by native driver or if emulated using Propel.
1225:      * @throws PropelException Any exceptions caught during processing will be
1226:      *       rethrown wrapped into a PropelException.
1227:      */
1228:      public static function doDelete($values, PropelPDO $con = null)
1229:      {
1230:         if ($con === null) {
1231:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1232:         }
1233: 
1234:         if ($values instanceof Criteria) {
1235:             // invalidate the cache for all objects of this type, since we have no
1236:             // way of knowing (without running a query) what objects should be invalidated
1237:             // from the cache based on this Criteria.
1238:             AccessoryPeer::clearInstancePool();
1239:             // rename for clarity
1240:             $criteria = clone $values;
1241:         } elseif ($values instanceof Accessory) { // it's a model object
1242:             // invalidate the cache for this single object
1243:             AccessoryPeer::removeInstanceFromPool($values);
1244:             // create criteria based on pk values
1245:             $criteria = $values->buildPkeyCriteria();
1246:         } else { // it's a primary key, or an array of pks
1247:             $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1248:             $criteria->add(AccessoryPeer::ID, (array) $values, Criteria::IN);
1249:             // invalidate the cache for this object(s)
1250:             foreach ((array) $values as $singleval) {
1251:                 AccessoryPeer::removeInstanceFromPool($singleval);
1252:             }
1253:         }
1254: 
1255:         // Set the correct dbName
1256:         $criteria->setDbName(AccessoryPeer::DATABASE_NAME);
1257: 
1258:         $affectedRows = 0; // initialize var to track total num of affected rows
1259: 
1260:         try {
1261:             // use transaction because $criteria could contain info
1262:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
1263:             $con->beginTransaction();
1264: 
1265:             $affectedRows += BasePeer::doDelete($criteria, $con);
1266:             AccessoryPeer::clearRelatedInstancePool();
1267:             $con->commit();
1268: 
1269:             return $affectedRows;
1270:         } catch (PropelException $e) {
1271:             $con->rollBack();
1272:             throw $e;
1273:         }
1274:     }
1275: 
1276:     /**
1277:      * Validates all modified columns of given Accessory object.
1278:      * If parameter $columns is either a single column name or an array of column names
1279:      * than only those columns are validated.
1280:      *
1281:      * NOTICE: This does not apply to primary or foreign keys for now.
1282:      *
1283:      * @param      Accessory $obj The object to validate.
1284:      * @param      mixed $cols Column name or array of column names.
1285:      *
1286:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
1287:      */
1288:     public static function doValidate($obj, $cols = null)
1289:     {
1290:         $columns = array();
1291: 
1292:         if ($cols) {
1293:             $dbMap = Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME);
1294:             $tableMap = $dbMap->getTable(AccessoryPeer::TABLE_NAME);
1295: 
1296:             if (! is_array($cols)) {
1297:                 $cols = array($cols);
1298:             }
1299: 
1300:             foreach ($cols as $colName) {
1301:                 if ($tableMap->hasColumn($colName)) {
1302:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
1303:                     $columns[$colName] = $obj->$get();
1304:                 }
1305:             }
1306:         } else {
1307: 
1308:         }
1309: 
1310:         return BasePeer::doValidate(AccessoryPeer::DATABASE_NAME, AccessoryPeer::TABLE_NAME, $columns);
1311:     }
1312: 
1313:     /**
1314:      * Retrieve a single object by pkey.
1315:      *
1316:      * @param      int $pk the primary key.
1317:      * @param      PropelPDO $con the connection to use
1318:      * @return Accessory
1319:      */
1320:     public static function retrieveByPK($pk, PropelPDO $con = null)
1321:     {
1322: 
1323:         if (null !== ($obj = AccessoryPeer::getInstanceFromPool((string) $pk))) {
1324:             return $obj;
1325:         }
1326: 
1327:         if ($con === null) {
1328:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1329:         }
1330: 
1331:         $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1332:         $criteria->add(AccessoryPeer::ID, $pk);
1333: 
1334:         $v = AccessoryPeer::doSelect($criteria, $con);
1335: 
1336:         return !empty($v) > 0 ? $v[0] : null;
1337:     }
1338: 
1339:     /**
1340:      * Retrieve multiple objects by pkey.
1341:      *
1342:      * @param      array $pks List of primary keys
1343:      * @param      PropelPDO $con the connection to use
1344:      * @return Accessory[]
1345:      * @throws PropelException Any exceptions caught during processing will be
1346:      *       rethrown wrapped into a PropelException.
1347:      */
1348:     public static function retrieveByPKs($pks, PropelPDO $con = null)
1349:     {
1350:         if ($con === null) {
1351:             $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1352:         }
1353: 
1354:         $objs = null;
1355:         if (empty($pks)) {
1356:             $objs = array();
1357:         } else {
1358:             $criteria = new Criteria(AccessoryPeer::DATABASE_NAME);
1359:             $criteria->add(AccessoryPeer::ID, $pks, Criteria::IN);
1360:             $objs = AccessoryPeer::doSelect($criteria, $con);
1361:         }
1362: 
1363:         return $objs;
1364:     }
1365: 
1366: } // BaseAccessoryPeer
1367: 
1368: // This is the static code needed to register the TableMap for this table with the main Propel class.
1369: //
1370: BaseAccessoryPeer::buildTableMap();
1371: 
1372: 
thelia API documentation generated by ApiGen 2.8.0