       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\CategoryPeer;
      13: use Thelia\Model\ContentAssoc;
      14: use Thelia\Model\ContentAssocPeer;
      15: use Thelia\Model\ContentPeer;
      16: use Thelia\Model\ProductPeer;
      17: use Thelia\Model\map\ContentAssocTableMap;
      18:
      19: /**
      20:  * Base static class for performing query and update operations on the 'content_assoc' table.
      21:  *
      22:  *
      23:  *
      24:  * @package propel.generator.Thelia.Model.om
      25:  */
      26: abstract class BaseContentAssocPeer
      27: {
      28:
      29:     /** the default database name for this class */
      30:     const DATABASE_NAME = 'thelia';
      31:
      32:     /** the table name for this class */
      33:     const TABLE_NAME = 'content_assoc';
      34:
      35:     /** the related Propel class for this table */
      36:     const OM_CLASS = 'Thelia\\Model\\ContentAssoc';
      37:
      38:     /** the related TableMap class for this table */
      39:     const TM_CLASS = 'ContentAssocTableMap';
      40:
      41:     /** The total number of columns. */
      42:     const NUM_COLUMNS = 7;
      43:
      44:     /** The number of lazy-loaded columns. */
      45:     const NUM_LAZY_LOAD_COLUMNS = 0;
      46:
      47:     /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
      48:     const NUM_HYDRATE_COLUMNS = 7;
      49:
      50:     /** the column name for the id field */
      51:     const ID = 'content_assoc.id';
      52:
      53:     /** the column name for the category_id field */
      54:     const CATEGORY_ID = 'content_assoc.category_id';
      55:
      56:     /** the column name for the product_id field */
      57:     const PRODUCT_ID = 'content_assoc.product_id';
      58:
      59:     /** the column name for the content_id field */
      60:     const CONTENT_ID = 'content_assoc.content_id';
      61:
      62:     /** the column name for the position field */
      63:     const POSITION = 'content_assoc.position';
      64:
      65:     /** the column name for the created_at field */
      66:     const CREATED_AT = 'content_assoc.created_at';
      67:
      68:     /** the column name for the updated_at field */
      69:     const UPDATED_AT = 'content_assoc.updated_at';
      70:
      71:     /** The default string format for model objects of the related table **/
      72:     const DEFAULT_STRING_FORMAT = 'YAML';
      73:
      74:     /**
      75:      * An identiy map to hold any loaded instances of ContentAssoc objects.
      76:      * This must be public so that other peer classes can access this when hydrating from JOIN
      77:      * queries.
      78:      * @var        array ContentAssoc[]
      79:      */
      80:     public static $instances = array();
      81:
      82:
      83:     /**
      84:      * holds an array of fieldnames
      85:      *
      86:      * first dimension keys are the type constants
      87:      * e.g. ContentAssocPeer::$fieldNames[ContentAssocPeer::TYPE_PHPNAME][0] = 'Id'
      88:      */
      89:     protected static $fieldNames = array (
      90:         BasePeer::TYPE_PHPNAME => array ('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ),
      91:         BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ),
      92:         BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID, ContentAssocPeer::CATEGORY_ID, ContentAssocPeer::PRODUCT_ID, ContentAssocPeer::CONTENT_ID, ContentAssocPeer::POSITION, ContentAssocPeer::CREATED_AT, ContentAssocPeer::UPDATED_AT, ),
      93:         BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
      94:         BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ),
      95:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
      96:     );
      97:
      98:     /**
      99:      * holds an array of keys for quick access to the fieldnames array
     100:      *
     101:      * first dimension keys are the type constants
     102:      * e.g. ContentAssocPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
     103:      */
     104:     protected static $fieldKeys = array (
     105:         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
     106:         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
     107:         BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID => 0, ContentAssocPeer::CATEGORY_ID => 1, ContentAssocPeer::PRODUCT_ID => 2, ContentAssocPeer::CONTENT_ID => 3, ContentAssocPeer::POSITION => 4, ContentAssocPeer::CREATED_AT => 5, ContentAssocPeer::UPDATED_AT => 6, ),
     108:         BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
     109:         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
     110:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
     111:     );
     112:
     113:     /**
     114:      * Translates a fieldname to another type
     115:      *
     116:      * @param      string $name field name
     117:      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     118:      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     119:      * @param      string $toType   One of the class type constants
     120:      * @return string          translated name of the field.
     121:      * @throws PropelException - if the specified name could not be found in the fieldname mappings.
     122:      */
     123:     public static function translateFieldName($name, $fromType, $toType)
     124:     {
     125:         $toNames = ContentAssocPeer::getFieldNames($toType);
     126:         $key = isset(ContentAssocPeer::$fieldKeys[$fromType][$name]) ? ContentAssocPeer::$fieldKeys[$fromType][$name] : null;
     127:         if ($key === null) {
     128:             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentAssocPeer::$fieldKeys[$fromType], true));
     129:         }
     130:
     131:         return $toNames[$key];
     132:     }
     133:
     134:     /**
     135:      * Returns an array of field names.
     136:      *
     137:      * @param      string $type The type of fieldnames to return:
     138:      *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     139:      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     140:      * @return array           A list of field names
     141:      * @throws PropelException - if the type is not valid.
     142:      */
     143:     public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
     144:     {
     145:         if (!array_key_exists($type, ContentAssocPeer::$fieldNames)) {
     146:             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.');
     147:         }
     148:
     149:         return ContentAssocPeer::$fieldNames[$type];
     150:     }
     151:
     152:     /**
     153:      * Convenience method which changes table.column to alias.column.
     154:      *
     155:      * Using this method you can maintain SQL abstraction while using column aliases.
     156:      * <code>
     157:      *      $c->addAlias("alias1", TablePeer::TABLE_NAME);
     158:      *      $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
     159:      * </code>
     160:      * @param      string $alias The alias for the current table.
     161:      * @param      string $column The column name for current table. (i.e. ContentAssocPeer::COLUMN_NAME).
     162:      * @return string
     163:      */
     164:     public static function alias($alias, $column)
     165:     {
     166:         return str_replace(ContentAssocPeer::TABLE_NAME.'.', $alias.'.', $column);
     167:     }
     168:
     169:     /**
     170:      * Add all the columns needed to create a new object.
     171:      *
     172:      * Note: any columns that were marked with lazyLoad="true" in the
     173:      * XML schema will not be added to the select list and only loaded
     174:      * on demand.
     175:      *
     176:      * @param      Criteria $criteria object containing the columns to add.
     177:      * @param      string   $alias    optional table alias
     178:      * @throws PropelException Any exceptions caught during processing will be
     179:      *       rethrown wrapped into a PropelException.
     180:      */
     181:     public static function addSelectColumns(Criteria $criteria, $alias = null)
     182:     {
     183:         if (null === $alias) {
     184:             $criteria->addSelectColumn(ContentAssocPeer::ID);
     185:             $criteria->addSelectColumn(ContentAssocPeer::CATEGORY_ID);
     186:             $criteria->addSelectColumn(ContentAssocPeer::PRODUCT_ID);
     187:             $criteria->addSelectColumn(ContentAssocPeer::CONTENT_ID);
     188:             $criteria->addSelectColumn(ContentAssocPeer::POSITION);
     189:             $criteria->addSelectColumn(ContentAssocPeer::CREATED_AT);
     190:             $criteria->addSelectColumn(ContentAssocPeer::UPDATED_AT);
     191:         } else {
     192:             $criteria->addSelectColumn($alias . '.id');
     193:             $criteria->addSelectColumn($alias . '.category_id');
     194:             $criteria->addSelectColumn($alias . '.product_id');
     195:             $criteria->addSelectColumn($alias . '.content_id');
     196:             $criteria->addSelectColumn($alias . '.position');
     197:             $criteria->addSelectColumn($alias . '.created_at');
     198:             $criteria->addSelectColumn($alias . '.updated_at');
     199:         }
     200:     }
     201:
     202:     /**
     203:      * Returns the number of rows matching criteria.
     204:      *
     205:      * @param      Criteria $criteria
     206:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     207:      * @param      PropelPDO $con
     208:      * @return int Number of matching rows.
     209:      */
     210:     public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
     211:     {
     212:         // we may modify criteria, so copy it first
     213:         $criteria = clone $criteria;
     214:
     215:         // We need to set the primary table name, since in the case that there are no WHERE columns
     216:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     217:         // tables go into the FROM clause.
     218:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
     219:
     220:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     221:             $criteria->setDistinct();
     222:         }
     223:
     224:         if (!$criteria->hasSelectClause()) {
     225:             ContentAssocPeer::addSelectColumns($criteria);
     226:         }
     227:
     228:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     229:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); // Set the correct dbName
     230:
     231:         if ($con === null) {
     232:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     233:         }
     234:         // BasePeer returns a PDOStatement
     235:         $stmt = BasePeer::doCount($criteria, $con);
     236:
     237:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     238:             $count = (int) $row[0];
     239:         } else {
     240:             $count = 0; // no rows returned; we infer that means 0 matches.
     241:         }
     242:         $stmt->closeCursor();
     243:
     244:         return $count;
     245:     }
     246:     /**
     247:      * Selects one object from the DB.
     248:      *
     249:      * @param      Criteria $criteria object used to create the SELECT statement.
     250:      * @param      PropelPDO $con
     251:      * @return                 ContentAssoc
     252:      * @throws PropelException Any exceptions caught during processing will be
     253:      *       rethrown wrapped into a PropelException.
     254:      */
     255:     public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
     256:     {
     257:         $critcopy = clone $criteria;
     258:         $critcopy->setLimit(1);
     259:         $objects = ContentAssocPeer::doSelect($critcopy, $con);
     260:         if ($objects) {
     261:             return $objects[0];
     262:         }
     263:
     264:         return null;
     265:     }
     266:     /**
     267:      * Selects several row from the DB.
     268:      *
     269:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     270:      * @param      PropelPDO $con
     271:      * @return array           Array of selected Objects
     272:      * @throws PropelException Any exceptions caught during processing will be
     273:      *       rethrown wrapped into a PropelException.
     274:      */
     275:     public static function doSelect(Criteria $criteria, PropelPDO $con = null)
     276:     {
     277:         return ContentAssocPeer::populateObjects(ContentAssocPeer::doSelectStmt($criteria, $con));
     278:     }
     279:     /**
     280:      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
     281:      *
     282:      * Use this method directly if you want to work with an executed statement directly (for example
     283:      * to perform your own object hydration).
     284:      *
     285:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     286:      * @param      PropelPDO $con The connection to use
     287:      * @throws PropelException Any exceptions caught during processing will be
     288:      *       rethrown wrapped into a PropelException.
     289:      * @return PDOStatement The executed PDOStatement object.
     290:      * @see        BasePeer::doSelect()
     291:      */
     292:     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
     293:     {
     294:         if ($con === null) {
     295:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     296:         }
     297:
     298:         if (!$criteria->hasSelectClause()) {
     299:             $criteria = clone $criteria;
     300:             ContentAssocPeer::addSelectColumns($criteria);
     301:         }
     302:
     303:         // Set the correct dbName
     304:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     305:
     306:         // BasePeer returns a PDOStatement
     307:         return BasePeer::doSelect($criteria, $con);
     308:     }
     309:     /**
     310:      * Adds an object to the instance pool.
     311:      *
     312:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
     313:      * from the database.  In some cases -- especially when you override doSelect*()
     314:      * methods in your stub classes -- you may need to explicitly add objects
     315:      * to the cache in order to ensure that the same objects are always returned by doSelect*()
     316:      * and retrieveByPK*() calls.
     317:      *
     318:      * @param      ContentAssoc $obj A ContentAssoc object.
     319:      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
     320:      */
     321:     public static function addInstanceToPool($obj, $key = null)
     322:     {
     323:         if (Propel::isInstancePoolingEnabled()) {
     324:             if ($key === null) {
     325:                 $key = (string) $obj->getId();
     326:             } // if key === null
     327:             ContentAssocPeer::$instances[$key] = $obj;
     328:         }
     329:     }
     330:
     331:     /**
     332:      * Removes an object from the instance pool.
     333:      *
     334:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
     335:      * from the database.  In some cases -- especially when you override doDelete
     336:      * methods in your stub classes -- you may need to explicitly remove objects
     337:      * from the cache in order to prevent returning objects that no longer exist.
     338:      *
     339:      * @param      mixed $value A ContentAssoc object or a primary key value.
     340:      *
     341:      * @return void
     342:      * @throws PropelException - if the value is invalid.
     343:      */
     344:     public static function removeInstanceFromPool($value)
     345:     {
     346:         if (Propel::isInstancePoolingEnabled() && $value !== null) {
     347:             if (is_object($value) && $value instanceof ContentAssoc) {
     348:                 $key = (string) $value->getId();
     349:             } elseif (is_scalar($value)) {
     350:                 // assume we've been passed a primary key
     351:                 $key = (string) $value;
     352:             } else {
     353:                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or ContentAssoc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
     354:                 throw $e;
     355:             }
     356:
     357:             unset(ContentAssocPeer::$instances[$key]);
     358:         }
     359:     } // removeInstanceFromPool()
     360:
     361:     /**
     362:      * 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.
     363:      *
     364:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     365:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
     366:      *
     367:      * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
     368:      * @return   ContentAssoc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
     369:      * @see        getPrimaryKeyHash()
     370:      */
     371:     public static function getInstanceFromPool($key)
     372:     {
     373:         if (Propel::isInstancePoolingEnabled()) {
     374:             if (isset(ContentAssocPeer::$instances[$key])) {
     375:                 return ContentAssocPeer::$instances[$key];
     376:             }
     377:         }
     378:
     379:         return null; // just to be explicit
     380:     }
     381:
     382:     /**
     383:      * Clear the instance pool.
     384:      *
     385:      * @return void
     386:      */
     387:     public static function clearInstancePool($and_clear_all_references = false)
     388:     {
     389:       if ($and_clear_all_references)
     390:       {
     391:         foreach (ContentAssocPeer::$instances as $instance)
     392:         {
     393:           $instance->clearAllReferences(true);
     394:         }
     395:       }
     396:         ContentAssocPeer::$instances = array();
     397:     }
     398:
     399:     /**
     400:      * Method to invalidate the instance pool of all tables related to content_assoc
     401:      * by a foreign key with ON DELETE CASCADE
     402:      */
     403:     public static function clearRelatedInstancePool()
     404:     {
     405:     }
     406:
     407:     /**
     408:      * 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.
     409:      *
     410:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     411:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
     412:      *
     413:      * @param      array $row PropelPDO resultset row.
     414:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     415:      * @return string A string version of PK or null if the components of primary key in result array are all null.
     416:      */
     417:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
     418:     {
     419:         // If the PK cannot be derived from the row, return null.
     420:         if ($row[$startcol] === null) {
     421:             return null;
     422:         }
     423:
     424:         return (string) $row[$startcol];
     425:     }
     426:
     427:     /**
     428:      * Retrieves the primary key from the DB resultset row
     429:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     430:      * a multi-column primary key, an array of the primary key columns will be returned.
     431:      *
     432:      * @param      array $row PropelPDO resultset row.
     433:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     434:      * @return mixed The primary key of the row
     435:      */
     436:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
     437:     {
     438:
     439:         return (int) $row[$startcol];
     440:     }
     441:
     442:     /**
     443:      * The returned array will contain objects of the default type or
     444:      * objects that inherit from the default.
     445:      *
     446:      * @throws PropelException Any exceptions caught during processing will be
     447:      *       rethrown wrapped into a PropelException.
     448:      */
     449:     public static function populateObjects(PDOStatement $stmt)
     450:     {
     451:         $results = array();
     452:
     453:         // set the class once to avoid overhead in the loop
     454:         $cls = ContentAssocPeer::getOMClass();
     455:         // populate the object(s)
     456:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     457:             $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
     458:             if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) {
     459:                 // We no longer rehydrate the object, since this can cause data loss.
     460:                 // See http://www.propelorm.org/ticket/509
     461:                 // $obj->hydrate($row, 0, true); // rehydrate
     462:                 $results[] = $obj;
     463:             } else {
     464:                 $obj = new $cls();
     465:                 $obj->hydrate($row);
     466:                 $results[] = $obj;
     467:                 ContentAssocPeer::addInstanceToPool($obj, $key);
     468:             } // if key exists
     469:         }
     470:         $stmt->closeCursor();
     471:
     472:         return $results;
     473:     }
     474:     /**
     475:      * Populates an object of the default type or an object that inherit from the default.
     476:      *
     477:      * @param      array $row PropelPDO resultset row.
     478:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     479:      * @throws PropelException Any exceptions caught during processing will be
     480:      *       rethrown wrapped into a PropelException.
     481:      * @return array (ContentAssoc object, last column rank)
     482:      */
     483:     public static function populateObject($row, $startcol = 0)
     484:     {
     485:         $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol);
     486:         if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) {
     487:             // We no longer rehydrate the object, since this can cause data loss.
     488:             // See http://www.propelorm.org/ticket/509
     489:             // $obj->hydrate($row, $startcol, true); // rehydrate
     490:             $col = $startcol + ContentAssocPeer::NUM_HYDRATE_COLUMNS;
     491:         } else {
     492:             $cls = ContentAssocPeer::OM_CLASS;
     493:             $obj = new $cls();
     494:             $col = $obj->hydrate($row, $startcol);
     495:             ContentAssocPeer::addInstanceToPool($obj, $key);
     496:         }
     497:
     498:         return array($obj, $col);
     499:     }
     500:
     501:
     502:     /**
     503:      * Returns the number of rows matching criteria, joining the related Category table
     504:      *
     505:      * @param      Criteria $criteria
     506:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     507:      * @param      PropelPDO $con
     508:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     509:      * @return int Number of matching rows.
     510:      */
     511:     public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     512:     {
     513:         // we're going to modify criteria, so copy it first
     514:         $criteria = clone $criteria;
     515:
     516:         // We need to set the primary table name, since in the case that there are no WHERE columns
     517:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     518:         // tables go into the FROM clause.
     519:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
     520:
     521:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     522:             $criteria->setDistinct();
     523:         }
     524:
     525:         if (!$criteria->hasSelectClause()) {
     526:             ContentAssocPeer::addSelectColumns($criteria);
     527:         }
     528:
     529:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     530:
     531:         // Set the correct dbName
     532:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     533:
     534:         if ($con === null) {
     535:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     536:         }
     537:
     538:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
     539:
     540:         $stmt = BasePeer::doCount($criteria, $con);
     541:
     542:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     543:             $count = (int) $row[0];
     544:         } else {
     545:             $count = 0; // no rows returned; we infer that means 0 matches.
     546:         }
     547:         $stmt->closeCursor();
     548:
     549:         return $count;
     550:     }
     551:
     552:
     553:     /**
     554:      * Returns the number of rows matching criteria, joining the related Product table
     555:      *
     556:      * @param      Criteria $criteria
     557:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     558:      * @param      PropelPDO $con
     559:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     560:      * @return int Number of matching rows.
     561:      */
     562:     public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     563:     {
     564:         // we're going to modify criteria, so copy it first
     565:         $criteria = clone $criteria;
     566:
     567:         // We need to set the primary table name, since in the case that there are no WHERE columns
     568:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     569:         // tables go into the FROM clause.
     570:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
     571:
     572:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     573:             $criteria->setDistinct();
     574:         }
     575:
     576:         if (!$criteria->hasSelectClause()) {
     577:             ContentAssocPeer::addSelectColumns($criteria);
     578:         }
     579:
     580:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     581:
     582:         // Set the correct dbName
     583:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     584:
     585:         if ($con === null) {
     586:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     587:         }
     588:
     589:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
     590:
     591:         $stmt = BasePeer::doCount($criteria, $con);
     592:
     593:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     594:             $count = (int) $row[0];
     595:         } else {
     596:             $count = 0; // no rows returned; we infer that means 0 matches.
     597:         }
     598:         $stmt->closeCursor();
     599:
     600:         return $count;
     601:     }
     602:
     603:
     604:     /**
     605:      * Returns the number of rows matching criteria, joining the related Content table
     606:      *
     607:      * @param      Criteria $criteria
     608:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     609:      * @param      PropelPDO $con
     610:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     611:      * @return int Number of matching rows.
     612:      */
     613:     public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     614:     {
     615:         // we're going to modify criteria, so copy it first
     616:         $criteria = clone $criteria;
     617:
     618:         // We need to set the primary table name, since in the case that there are no WHERE columns
     619:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     620:         // tables go into the FROM clause.
     621:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
     622:
     623:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     624:             $criteria->setDistinct();
     625:         }
     626:
     627:         if (!$criteria->hasSelectClause()) {
     628:             ContentAssocPeer::addSelectColumns($criteria);
     629:         }
     630:
     631:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     632:
     633:         // Set the correct dbName
     634:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     635:
     636:         if ($con === null) {
     637:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     638:         }
     639:
     640:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
     641:
     642:         $stmt = BasePeer::doCount($criteria, $con);
     643:
     644:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     645:             $count = (int) $row[0];
     646:         } else {
     647:             $count = 0; // no rows returned; we infer that means 0 matches.
     648:         }
     649:         $stmt->closeCursor();
     650:
     651:         return $count;
     652:     }
     653:
     654:
     655:     /**
     656:      * Selects a collection of ContentAssoc objects pre-filled with their Category objects.
     657:      * @param      Criteria  $criteria
     658:      * @param      PropelPDO $con
     659:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     660:      * @return array           Array of ContentAssoc objects.
     661:      * @throws PropelException Any exceptions caught during processing will be
     662:      *       rethrown wrapped into a PropelException.
     663:      */
     664:     public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     665:     {
     666:         $criteria = clone $criteria;
     667:
     668:         // Set the correct dbName if it has not been overridden
     669:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     670:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     671:         }
     672:
     673:         ContentAssocPeer::addSelectColumns($criteria);
     674:         $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
     675:         CategoryPeer::addSelectColumns($criteria);
     676:
     677:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
     678:
     679:         $stmt = BasePeer::doSelect($criteria, $con);
     680:         $results = array();
     681:
     682:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     683:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
     684:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
     685:                 // We no longer rehydrate the object, since this can cause data loss.
     686:                 // See http://www.propelorm.org/ticket/509
     687:                 // $obj1->hydrate($row, 0, true); // rehydrate
     688:             } else {
     689:
     690:                 $cls = ContentAssocPeer::getOMClass();
     691:
     692:                 $obj1 = new $cls();
     693:                 $obj1->hydrate($row);
     694:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
     695:             } // if $obj1 already loaded
     696:
     697:             $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol);
     698:             if ($key2 !== null) {
     699:                 $obj2 = CategoryPeer::getInstanceFromPool($key2);
     700:                 if (!$obj2) {
     701:
     702:                     $cls = CategoryPeer::getOMClass();
     703:
     704:                     $obj2 = new $cls();
     705:                     $obj2->hydrate($row, $startcol);
     706:                     CategoryPeer::addInstanceToPool($obj2, $key2);
     707:                 } // if obj2 already loaded
     708:
     709:                 // Add the $obj1 (ContentAssoc) to $obj2 (Category)
     710:                 $obj2->addContentAssoc($obj1);
     711:
     712:             } // if joined row was not null
     713:
     714:             $results[] = $obj1;
     715:         }
     716:         $stmt->closeCursor();
     717:
     718:         return $results;
     719:     }
     720:
     721:
     722:     /**
     723:      * Selects a collection of ContentAssoc objects pre-filled with their Product objects.
     724:      * @param      Criteria  $criteria
     725:      * @param      PropelPDO $con
     726:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     727:      * @return array           Array of ContentAssoc objects.
     728:      * @throws PropelException Any exceptions caught during processing will be
     729:      *       rethrown wrapped into a PropelException.
     730:      */
     731:     public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     732:     {
     733:         $criteria = clone $criteria;
     734:
     735:         // Set the correct dbName if it has not been overridden
     736:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     737:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     738:         }
     739:
     740:         ContentAssocPeer::addSelectColumns($criteria);
     741:         $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
     742:         ProductPeer::addSelectColumns($criteria);
     743:
     744:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
     745:
     746:         $stmt = BasePeer::doSelect($criteria, $con);
     747:         $results = array();
     748:
     749:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     750:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
     751:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
     752:                 // We no longer rehydrate the object, since this can cause data loss.
     753:                 // See http://www.propelorm.org/ticket/509
     754:                 // $obj1->hydrate($row, 0, true); // rehydrate
     755:             } else {
     756:
     757:                 $cls = ContentAssocPeer::getOMClass();
     758:
     759:                 $obj1 = new $cls();
     760:                 $obj1->hydrate($row);
     761:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
     762:             } // if $obj1 already loaded
     763:
     764:             $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol);
     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, $startcol);
     773:                     ProductPeer::addInstanceToPool($obj2, $key2);
     774:                 } // if obj2 already loaded
     775:
     776:                 // Add the $obj1 (ContentAssoc) to $obj2 (Product)
     777:                 $obj2->addContentAssoc($obj1);
     778:
     779:             } // if joined row was not null
     780:
     781:             $results[] = $obj1;
     782:         }
     783:         $stmt->closeCursor();
     784:
     785:         return $results;
     786:     }
     787:
     788:
     789:     /**
     790:      * Selects a collection of ContentAssoc objects pre-filled with their Content objects.
     791:      * @param      Criteria  $criteria
     792:      * @param      PropelPDO $con
     793:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     794:      * @return array           Array of ContentAssoc objects.
     795:      * @throws PropelException Any exceptions caught during processing will be
     796:      *       rethrown wrapped into a PropelException.
     797:      */
     798:     public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     799:     {
     800:         $criteria = clone $criteria;
     801:
     802:         // Set the correct dbName if it has not been overridden
     803:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     804:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     805:         }
     806:
     807:         ContentAssocPeer::addSelectColumns($criteria);
     808:         $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
     809:         ContentPeer::addSelectColumns($criteria);
     810:
     811:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
     812:
     813:         $stmt = BasePeer::doSelect($criteria, $con);
     814:         $results = array();
     815:
     816:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     817:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
     818:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
     819:                 // We no longer rehydrate the object, since this can cause data loss.
     820:                 // See http://www.propelorm.org/ticket/509
     821:                 // $obj1->hydrate($row, 0, true); // rehydrate
     822:             } else {
     823:
     824:                 $cls = ContentAssocPeer::getOMClass();
     825:
     826:                 $obj1 = new $cls();
     827:                 $obj1->hydrate($row);
     828:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
     829:             } // if $obj1 already loaded
     830:
     831:             $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol);
     832:             if ($key2 !== null) {
     833:                 $obj2 = ContentPeer::getInstanceFromPool($key2);
     834:                 if (!$obj2) {
     835:
     836:                     $cls = ContentPeer::getOMClass();
     837:
     838:                     $obj2 = new $cls();
     839:                     $obj2->hydrate($row, $startcol);
     840:                     ContentPeer::addInstanceToPool($obj2, $key2);
     841:                 } // if obj2 already loaded
     842:
     843:                 // Add the $obj1 (ContentAssoc) to $obj2 (Content)
     844:                 $obj2->addContentAssoc($obj1);
     845:
     846:             } // if joined row was not null
     847:
     848:             $results[] = $obj1;
     849:         }
     850:         $stmt->closeCursor();
     851:
     852:         return $results;
     853:     }
     854:
     855:
     856:     /**
     857:      * Returns the number of rows matching criteria, joining all related tables
     858:      *
     859:      * @param      Criteria $criteria
     860:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     861:      * @param      PropelPDO $con
     862:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     863:      * @return int Number of matching rows.
     864:      */
     865:     public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     866:     {
     867:         // we're going to modify criteria, so copy it first
     868:         $criteria = clone $criteria;
     869:
     870:         // We need to set the primary table name, since in the case that there are no WHERE columns
     871:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     872:         // tables go into the FROM clause.
     873:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
     874:
     875:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     876:             $criteria->setDistinct();
     877:         }
     878:
     879:         if (!$criteria->hasSelectClause()) {
     880:             ContentAssocPeer::addSelectColumns($criteria);
     881:         }
     882:
     883:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     884:
     885:         // Set the correct dbName
     886:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     887:
     888:         if ($con === null) {
     889:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     890:         }
     891:
     892:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
     893:
     894:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
     895:
     896:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
     897:
     898:         $stmt = BasePeer::doCount($criteria, $con);
     899:
     900:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     901:             $count = (int) $row[0];
     902:         } else {
     903:             $count = 0; // no rows returned; we infer that means 0 matches.
     904:         }
     905:         $stmt->closeCursor();
     906:
     907:         return $count;
     908:     }
     909:
     910:     /**
     911:      * Selects a collection of ContentAssoc objects pre-filled with all related objects.
     912:      *
     913:      * @param      Criteria  $criteria
     914:      * @param      PropelPDO $con
     915:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     916:      * @return array           Array of ContentAssoc objects.
     917:      * @throws PropelException Any exceptions caught during processing will be
     918:      *       rethrown wrapped into a PropelException.
     919:      */
     920:     public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     921:     {
     922:         $criteria = clone $criteria;
     923:
     924:         // Set the correct dbName if it has not been overridden
     925:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     926:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
     927:         }
     928:
     929:         ContentAssocPeer::addSelectColumns($criteria);
     930:         $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
     931:
     932:         CategoryPeer::addSelectColumns($criteria);
     933:         $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
     934:
     935:         ProductPeer::addSelectColumns($criteria);
     936:         $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
     937:
     938:         ContentPeer::addSelectColumns($criteria);
     939:         $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS;
     940:
     941:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
     942:
     943:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
     944:
     945:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
     946:
     947:         $stmt = BasePeer::doSelect($criteria, $con);
     948:         $results = array();
     949:
     950:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     951:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
     952:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
     953:                 // We no longer rehydrate the object, since this can cause data loss.
     954:                 // See http://www.propelorm.org/ticket/509
     955:                 // $obj1->hydrate($row, 0, true); // rehydrate
     956:             } else {
     957:                 $cls = ContentAssocPeer::getOMClass();
     958:
     959:                 $obj1 = new $cls();
     960:                 $obj1->hydrate($row);
     961:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
     962:             } // if obj1 already loaded
     963:
     964:             // Add objects for joined Category rows
     965:
     966:             $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
     967:             if ($key2 !== null) {
     968:                 $obj2 = CategoryPeer::getInstanceFromPool($key2);
     969:                 if (!$obj2) {
     970:
     971:                     $cls = CategoryPeer::getOMClass();
     972:
     973:                     $obj2 = new $cls();
     974:                     $obj2->hydrate($row, $startcol2);
     975:                     CategoryPeer::addInstanceToPool($obj2, $key2);
     976:                 } // if obj2 loaded
     977:
     978:                 // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
     979:                 $obj2->addContentAssoc($obj1);
     980:             } // if joined row not null
     981:
     982:             // Add objects for joined Product rows
     983:
     984:             $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
     985:             if ($key3 !== null) {
     986:                 $obj3 = ProductPeer::getInstanceFromPool($key3);
     987:                 if (!$obj3) {
     988:
     989:                     $cls = ProductPeer::getOMClass();
     990:
     991:                     $obj3 = new $cls();
     992:                     $obj3->hydrate($row, $startcol3);
     993:                     ProductPeer::addInstanceToPool($obj3, $key3);
     994:                 } // if obj3 loaded
     995:
     996:                 // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product)
     997:                 $obj3->addContentAssoc($obj1);
     998:             } // if joined row not null
     999:
    1000:             // Add objects for joined Content rows
    1001:
    1002:             $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    1003:             if ($key4 !== null) {
    1004:                 $obj4 = ContentPeer::getInstanceFromPool($key4);
    1005:                 if (!$obj4) {
    1006:
    1007:                     $cls = ContentPeer::getOMClass();
    1008:
    1009:                     $obj4 = new $cls();
    1010:                     $obj4->hydrate($row, $startcol4);
    1011:                     ContentPeer::addInstanceToPool($obj4, $key4);
    1012:                 } // if obj4 loaded
    1013:
    1014:                 // Add the $obj1 (ContentAssoc) to the collection in $obj4 (Content)
    1015:                 $obj4->addContentAssoc($obj1);
    1016:             } // if joined row not null
    1017:
    1018:             $results[] = $obj1;
    1019:         }
    1020:         $stmt->closeCursor();
    1021:
    1022:         return $results;
    1023:     }
    1024:
    1025:
    1026:     /**
    1027:      * Returns the number of rows matching criteria, joining the related Category table
    1028:      *
    1029:      * @param      Criteria $criteria
    1030:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1031:      * @param      PropelPDO $con
    1032:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1033:      * @return int Number of matching rows.
    1034:      */
    1035:     public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1036:     {
    1037:         // we're going to modify criteria, so copy it first
    1038:         $criteria = clone $criteria;
    1039:
    1040:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1041:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1042:         // tables go into the FROM clause.
    1043:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
    1044:
    1045:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1046:             $criteria->setDistinct();
    1047:         }
    1048:
    1049:         if (!$criteria->hasSelectClause()) {
    1050:             ContentAssocPeer::addSelectColumns($criteria);
    1051:         }
    1052:
    1053:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1054:
    1055:         // Set the correct dbName
    1056:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1057:
    1058:         if ($con === null) {
    1059:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1060:         }
    1061:
    1062:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
    1063:
    1064:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
    1065:
    1066:         $stmt = BasePeer::doCount($criteria, $con);
    1067:
    1068:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1069:             $count = (int) $row[0];
    1070:         } else {
    1071:             $count = 0; // no rows returned; we infer that means 0 matches.
    1072:         }
    1073:         $stmt->closeCursor();
    1074:
    1075:         return $count;
    1076:     }
    1077:
    1078:
    1079:     /**
    1080:      * Returns the number of rows matching criteria, joining the related Product table
    1081:      *
    1082:      * @param      Criteria $criteria
    1083:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1084:      * @param      PropelPDO $con
    1085:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1086:      * @return int Number of matching rows.
    1087:      */
    1088:     public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1089:     {
    1090:         // we're going to modify criteria, so copy it first
    1091:         $criteria = clone $criteria;
    1092:
    1093:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1094:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1095:         // tables go into the FROM clause.
    1096:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
    1097:
    1098:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1099:             $criteria->setDistinct();
    1100:         }
    1101:
    1102:         if (!$criteria->hasSelectClause()) {
    1103:             ContentAssocPeer::addSelectColumns($criteria);
    1104:         }
    1105:
    1106:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1107:
    1108:         // Set the correct dbName
    1109:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1110:
    1111:         if ($con === null) {
    1112:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1113:         }
    1114:
    1115:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
    1116:
    1117:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
    1118:
    1119:         $stmt = BasePeer::doCount($criteria, $con);
    1120:
    1121:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1122:             $count = (int) $row[0];
    1123:         } else {
    1124:             $count = 0; // no rows returned; we infer that means 0 matches.
    1125:         }
    1126:         $stmt->closeCursor();
    1127:
    1128:         return $count;
    1129:     }
    1130:
    1131:
    1132:     /**
    1133:      * Returns the number of rows matching criteria, joining the related Content table
    1134:      *
    1135:      * @param      Criteria $criteria
    1136:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1137:      * @param      PropelPDO $con
    1138:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1139:      * @return int Number of matching rows.
    1140:      */
    1141:     public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1142:     {
    1143:         // we're going to modify criteria, so copy it first
    1144:         $criteria = clone $criteria;
    1145:
    1146:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1147:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1148:         // tables go into the FROM clause.
    1149:         $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
    1150:
    1151:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1152:             $criteria->setDistinct();
    1153:         }
    1154:
    1155:         if (!$criteria->hasSelectClause()) {
    1156:             ContentAssocPeer::addSelectColumns($criteria);
    1157:         }
    1158:
    1159:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1160:
    1161:         // Set the correct dbName
    1162:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1163:
    1164:         if ($con === null) {
    1165:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1166:         }
    1167:
    1168:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
    1169:
    1170:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
    1171:
    1172:         $stmt = BasePeer::doCount($criteria, $con);
    1173:
    1174:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1175:             $count = (int) $row[0];
    1176:         } else {
    1177:             $count = 0; // no rows returned; we infer that means 0 matches.
    1178:         }
    1179:         $stmt->closeCursor();
    1180:
    1181:         return $count;
    1182:     }
    1183:
    1184:
    1185:     /**
    1186:      * Selects a collection of ContentAssoc objects pre-filled with all related objects except Category.
    1187:      *
    1188:      * @param      Criteria  $criteria
    1189:      * @param      PropelPDO $con
    1190:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1191:      * @return array           Array of ContentAssoc objects.
    1192:      * @throws PropelException Any exceptions caught during processing will be
    1193:      *       rethrown wrapped into a PropelException.
    1194:      */
    1195:     public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1196:     {
    1197:         $criteria = clone $criteria;
    1198:
    1199:         // Set the correct dbName if it has not been overridden
    1200:         // $criteria->getDbName() will return the same object if not set to another value
    1201:         // so == check is okay and faster
    1202:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1203:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1204:         }
    1205:
    1206:         ContentAssocPeer::addSelectColumns($criteria);
    1207:         $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
    1208:
    1209:         ProductPeer::addSelectColumns($criteria);
    1210:         $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS;
    1211:
    1212:         ContentPeer::addSelectColumns($criteria);
    1213:         $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
    1214:
    1215:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
    1216:
    1217:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
    1218:
    1219:
    1220:         $stmt = BasePeer::doSelect($criteria, $con);
    1221:         $results = array();
    1222:
    1223:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1224:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
    1225:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
    1226:                 // We no longer rehydrate the object, since this can cause data loss.
    1227:                 // See http://www.propelorm.org/ticket/509
    1228:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1229:             } else {
    1230:                 $cls = ContentAssocPeer::getOMClass();
    1231:
    1232:                 $obj1 = new $cls();
    1233:                 $obj1->hydrate($row);
    1234:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
    1235:             } // if obj1 already loaded
    1236:
    1237:                 // Add objects for joined Product rows
    1238:
    1239:                 $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1240:                 if ($key2 !== null) {
    1241:                     $obj2 = ProductPeer::getInstanceFromPool($key2);
    1242:                     if (!$obj2) {
    1243:
    1244:                         $cls = ProductPeer::getOMClass();
    1245:
    1246:                     $obj2 = new $cls();
    1247:                     $obj2->hydrate($row, $startcol2);
    1248:                     ProductPeer::addInstanceToPool($obj2, $key2);
    1249:                 } // if $obj2 already loaded
    1250:
    1251:                 // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Product)
    1252:                 $obj2->addContentAssoc($obj1);
    1253:
    1254:             } // if joined row is not null
    1255:
    1256:                 // Add objects for joined Content rows
    1257:
    1258:                 $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1259:                 if ($key3 !== null) {
    1260:                     $obj3 = ContentPeer::getInstanceFromPool($key3);
    1261:                     if (!$obj3) {
    1262:
    1263:                         $cls = ContentPeer::getOMClass();
    1264:
    1265:                     $obj3 = new $cls();
    1266:                     $obj3->hydrate($row, $startcol3);
    1267:                     ContentPeer::addInstanceToPool($obj3, $key3);
    1268:                 } // if $obj3 already loaded
    1269:
    1270:                 // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content)
    1271:                 $obj3->addContentAssoc($obj1);
    1272:
    1273:             } // if joined row is not null
    1274:
    1275:             $results[] = $obj1;
    1276:         }
    1277:         $stmt->closeCursor();
    1278:
    1279:         return $results;
    1280:     }
    1281:
    1282:
    1283:     /**
    1284:      * Selects a collection of ContentAssoc objects pre-filled with all related objects except Product.
    1285:      *
    1286:      * @param      Criteria  $criteria
    1287:      * @param      PropelPDO $con
    1288:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1289:      * @return array           Array of ContentAssoc objects.
    1290:      * @throws PropelException Any exceptions caught during processing will be
    1291:      *       rethrown wrapped into a PropelException.
    1292:      */
    1293:     public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1294:     {
    1295:         $criteria = clone $criteria;
    1296:
    1297:         // Set the correct dbName if it has not been overridden
    1298:         // $criteria->getDbName() will return the same object if not set to another value
    1299:         // so == check is okay and faster
    1300:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1301:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1302:         }
    1303:
    1304:         ContentAssocPeer::addSelectColumns($criteria);
    1305:         $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
    1306:
    1307:         CategoryPeer::addSelectColumns($criteria);
    1308:         $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
    1309:
    1310:         ContentPeer::addSelectColumns($criteria);
    1311:         $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS;
    1312:
    1313:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
    1314:
    1315:         $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior);
    1316:
    1317:
    1318:         $stmt = BasePeer::doSelect($criteria, $con);
    1319:         $results = array();
    1320:
    1321:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1322:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
    1323:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
    1324:                 // We no longer rehydrate the object, since this can cause data loss.
    1325:                 // See http://www.propelorm.org/ticket/509
    1326:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1327:             } else {
    1328:                 $cls = ContentAssocPeer::getOMClass();
    1329:
    1330:                 $obj1 = new $cls();
    1331:                 $obj1->hydrate($row);
    1332:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
    1333:             } // if obj1 already loaded
    1334:
    1335:                 // Add objects for joined Category rows
    1336:
    1337:                 $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1338:                 if ($key2 !== null) {
    1339:                     $obj2 = CategoryPeer::getInstanceFromPool($key2);
    1340:                     if (!$obj2) {
    1341:
    1342:                         $cls = CategoryPeer::getOMClass();
    1343:
    1344:                     $obj2 = new $cls();
    1345:                     $obj2->hydrate($row, $startcol2);
    1346:                     CategoryPeer::addInstanceToPool($obj2, $key2);
    1347:                 } // if $obj2 already loaded
    1348:
    1349:                 // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
    1350:                 $obj2->addContentAssoc($obj1);
    1351:
    1352:             } // if joined row is not null
    1353:
    1354:                 // Add objects for joined Content rows
    1355:
    1356:                 $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1357:                 if ($key3 !== null) {
    1358:                     $obj3 = ContentPeer::getInstanceFromPool($key3);
    1359:                     if (!$obj3) {
    1360:
    1361:                         $cls = ContentPeer::getOMClass();
    1362:
    1363:                     $obj3 = new $cls();
    1364:                     $obj3->hydrate($row, $startcol3);
    1365:                     ContentPeer::addInstanceToPool($obj3, $key3);
    1366:                 } // if $obj3 already loaded
    1367:
    1368:                 // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content)
    1369:                 $obj3->addContentAssoc($obj1);
    1370:
    1371:             } // if joined row is not null
    1372:
    1373:             $results[] = $obj1;
    1374:         }
    1375:         $stmt->closeCursor();
    1376:
    1377:         return $results;
    1378:     }
    1379:
    1380:
    1381:     /**
    1382:      * Selects a collection of ContentAssoc objects pre-filled with all related objects except Content.
    1383:      *
    1384:      * @param      Criteria  $criteria
    1385:      * @param      PropelPDO $con
    1386:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1387:      * @return array           Array of ContentAssoc objects.
    1388:      * @throws PropelException Any exceptions caught during processing will be
    1389:      *       rethrown wrapped into a PropelException.
    1390:      */
    1391:     public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1392:     {
    1393:         $criteria = clone $criteria;
    1394:
    1395:         // Set the correct dbName if it has not been overridden
    1396:         // $criteria->getDbName() will return the same object if not set to another value
    1397:         // so == check is okay and faster
    1398:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1399:             $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1400:         }
    1401:
    1402:         ContentAssocPeer::addSelectColumns($criteria);
    1403:         $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS;
    1404:
    1405:         CategoryPeer::addSelectColumns($criteria);
    1406:         $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
    1407:
    1408:         ProductPeer::addSelectColumns($criteria);
    1409:         $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS;
    1410:
    1411:         $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
    1412:
    1413:         $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior);
    1414:
    1415:
    1416:         $stmt = BasePeer::doSelect($criteria, $con);
    1417:         $results = array();
    1418:
    1419:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1420:             $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0);
    1421:             if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) {
    1422:                 // We no longer rehydrate the object, since this can cause data loss.
    1423:                 // See http://www.propelorm.org/ticket/509
    1424:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1425:             } else {
    1426:                 $cls = ContentAssocPeer::getOMClass();
    1427:
    1428:                 $obj1 = new $cls();
    1429:                 $obj1->hydrate($row);
    1430:                 ContentAssocPeer::addInstanceToPool($obj1, $key1);
    1431:             } // if obj1 already loaded
    1432:
    1433:                 // Add objects for joined Category rows
    1434:
    1435:                 $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1436:                 if ($key2 !== null) {
    1437:                     $obj2 = CategoryPeer::getInstanceFromPool($key2);
    1438:                     if (!$obj2) {
    1439:
    1440:                         $cls = CategoryPeer::getOMClass();
    1441:
    1442:                     $obj2 = new $cls();
    1443:                     $obj2->hydrate($row, $startcol2);
    1444:                     CategoryPeer::addInstanceToPool($obj2, $key2);
    1445:                 } // if $obj2 already loaded
    1446:
    1447:                 // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category)
    1448:                 $obj2->addContentAssoc($obj1);
    1449:
    1450:             } // if joined row is not null
    1451:
    1452:                 // Add objects for joined Product rows
    1453:
    1454:                 $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1455:                 if ($key3 !== null) {
    1456:                     $obj3 = ProductPeer::getInstanceFromPool($key3);
    1457:                     if (!$obj3) {
    1458:
    1459:                         $cls = ProductPeer::getOMClass();
    1460:
    1461:                     $obj3 = new $cls();
    1462:                     $obj3->hydrate($row, $startcol3);
    1463:                     ProductPeer::addInstanceToPool($obj3, $key3);
    1464:                 } // if $obj3 already loaded
    1465:
    1466:                 // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product)
    1467:                 $obj3->addContentAssoc($obj1);
    1468:
    1469:             } // if joined row is not null
    1470:
    1471:             $results[] = $obj1;
    1472:         }
    1473:         $stmt->closeCursor();
    1474:
    1475:         return $results;
    1476:     }
    1477:
    1478:     /**
    1479:      * Returns the TableMap related to this peer.
    1480:      * This method is not needed for general use but a specific application could have a need.
    1481:      * @return TableMap
    1482:      * @throws PropelException Any exceptions caught during processing will be
    1483:      *       rethrown wrapped into a PropelException.
    1484:      */
    1485:     public static function getTableMap()
    1486:     {
    1487:         return Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME)->getTable(ContentAssocPeer::TABLE_NAME);
    1488:     }
    1489:
    1490:     /**
    1491:      * Add a TableMap instance to the database for this peer class.
    1492:      */
    1493:     public static function buildTableMap()
    1494:     {
    1495:       $dbMap = Propel::getDatabaseMap(BaseContentAssocPeer::DATABASE_NAME);
    1496:       if (!$dbMap->hasTable(BaseContentAssocPeer::TABLE_NAME)) {
    1497:         $dbMap->addTableObject(new ContentAssocTableMap());
    1498:       }
    1499:     }
    1500:
    1501:     /**
    1502:      * The class that the Peer will make instances of.
    1503:      *
    1504:      *
    1505:      * @return string ClassName
    1506:      */
    1507:     public static function getOMClass($row = 0, $colnum = 0)
    1508:     {
    1509:         return ContentAssocPeer::OM_CLASS;
    1510:     }
    1511:
    1512:     /**
    1513:      * Performs an INSERT on the database, given a ContentAssoc or Criteria object.
    1514:      *
    1515:      * @param      mixed $values Criteria or ContentAssoc object containing data that is used to create the INSERT statement.
    1516:      * @param      PropelPDO $con the PropelPDO connection to use
    1517:      * @return mixed           The new primary key.
    1518:      * @throws PropelException Any exceptions caught during processing will be
    1519:      *       rethrown wrapped into a PropelException.
    1520:      */
    1521:     public static function doInsert($values, PropelPDO $con = null)
    1522:     {
    1523:         if ($con === null) {
    1524:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    1525:         }
    1526:
    1527:         if ($values instanceof Criteria) {
    1528:             $criteria = clone $values; // rename for clarity
    1529:         } else {
    1530:             $criteria = $values->buildCriteria(); // build Criteria from ContentAssoc object
    1531:         }
    1532:
    1533:         if ($criteria->containsKey(ContentAssocPeer::ID) && $criteria->keyContainsValue(ContentAssocPeer::ID) ) {
    1534:             throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocPeer::ID.')');
    1535:         }
    1536:
    1537:
    1538:         // Set the correct dbName
    1539:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1540:
    1541:         try {
    1542:             // use transaction because $criteria could contain info
    1543:             // for more than one table (I guess, conceivably)
    1544:             $con->beginTransaction();
    1545:             $pk = BasePeer::doInsert($criteria, $con);
    1546:             $con->commit();
    1547:         } catch (PropelException $e) {
    1548:             $con->rollBack();
    1549:             throw $e;
    1550:         }
    1551:
    1552:         return $pk;
    1553:     }
    1554:
    1555:     /**
    1556:      * Performs an UPDATE on the database, given a ContentAssoc or Criteria object.
    1557:      *
    1558:      * @param      mixed $values Criteria or ContentAssoc object containing data that is used to create the UPDATE statement.
    1559:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
    1560:      * @return int             The number of affected rows (if supported by underlying database driver).
    1561:      * @throws PropelException Any exceptions caught during processing will be
    1562:      *       rethrown wrapped into a PropelException.
    1563:      */
    1564:     public static function doUpdate($values, PropelPDO $con = null)
    1565:     {
    1566:         if ($con === null) {
    1567:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    1568:         }
    1569:
    1570:         $selectCriteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
    1571:
    1572:         if ($values instanceof Criteria) {
    1573:             $criteria = clone $values; // rename for clarity
    1574:
    1575:             $comparison = $criteria->getComparison(ContentAssocPeer::ID);
    1576:             $value = $criteria->remove(ContentAssocPeer::ID);
    1577:             if ($value) {
    1578:                 $selectCriteria->add(ContentAssocPeer::ID, $value, $comparison);
    1579:             } else {
    1580:                 $selectCriteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME);
    1581:             }
    1582:
    1583:         } else { // $values is ContentAssoc object
    1584:             $criteria = $values->buildCriteria(); // gets full criteria
    1585:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
    1586:         }
    1587:
    1588:         // set the correct dbName
    1589:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1590:
    1591:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    1592:     }
    1593:
    1594:     /**
    1595:      * Deletes all rows from the content_assoc table.
    1596:      *
    1597:      * @param      PropelPDO $con the connection to use
    1598:      * @return int             The number of affected rows (if supported by underlying database driver).
    1599:      * @throws PropelException
    1600:      */
    1601:     public static function doDeleteAll(PropelPDO $con = null)
    1602:     {
    1603:         if ($con === null) {
    1604:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    1605:         }
    1606:         $affectedRows = 0; // initialize var to track total num of affected rows
    1607:         try {
    1608:             // use transaction because $criteria could contain info
    1609:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    1610:             $con->beginTransaction();
    1611:             $affectedRows += BasePeer::doDeleteAll(ContentAssocPeer::TABLE_NAME, $con, ContentAssocPeer::DATABASE_NAME);
    1612:             // Because this db requires some delete cascade/set null emulation, we have to
    1613:             // clear the cached instance *after* the emulation has happened (since
    1614:             // instances get re-added by the select statement contained therein).
    1615:             ContentAssocPeer::clearInstancePool();
    1616:             ContentAssocPeer::clearRelatedInstancePool();
    1617:             $con->commit();
    1618:
    1619:             return $affectedRows;
    1620:         } catch (PropelException $e) {
    1621:             $con->rollBack();
    1622:             throw $e;
    1623:         }
    1624:     }
    1625:
    1626:     /**
    1627:      * Performs a DELETE on the database, given a ContentAssoc or Criteria object OR a primary key value.
    1628:      *
    1629:      * @param      mixed $values Criteria or ContentAssoc object or primary key or array of primary keys
    1630:      *              which is used to create the DELETE statement
    1631:      * @param      PropelPDO $con the connection to use
    1632:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
    1633:      *              if supported by native driver or if emulated using Propel.
    1634:      * @throws PropelException Any exceptions caught during processing will be
    1635:      *       rethrown wrapped into a PropelException.
    1636:      */
    1637:      public static function doDelete($values, PropelPDO $con = null)
    1638:      {
    1639:         if ($con === null) {
    1640:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    1641:         }
    1642:
    1643:         if ($values instanceof Criteria) {
    1644:             // invalidate the cache for all objects of this type, since we have no
    1645:             // way of knowing (without running a query) what objects should be invalidated
    1646:             // from the cache based on this Criteria.
    1647:             ContentAssocPeer::clearInstancePool();
    1648:             // rename for clarity
    1649:             $criteria = clone $values;
    1650:         } elseif ($values instanceof ContentAssoc) { // it's a model object
    1651:             // invalidate the cache for this single object
    1652:             ContentAssocPeer::removeInstanceFromPool($values);
    1653:             // create criteria based on pk values
    1654:             $criteria = $values->buildPkeyCriteria();
    1655:         } else { // it's a primary key, or an array of pks
    1656:             $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
    1657:             $criteria->add(ContentAssocPeer::ID, (array) $values, Criteria::IN);
    1658:             // invalidate the cache for this object(s)
    1659:             foreach ((array) $values as $singleval) {
    1660:                 ContentAssocPeer::removeInstanceFromPool($singleval);
    1661:             }
    1662:         }
    1663:
    1664:         // Set the correct dbName
    1665:         $criteria->setDbName(ContentAssocPeer::DATABASE_NAME);
    1666:
    1667:         $affectedRows = 0; // initialize var to track total num of affected rows
    1668:
    1669:         try {
    1670:             // use transaction because $criteria could contain info
    1671:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    1672:             $con->beginTransaction();
    1673:
    1674:             $affectedRows += BasePeer::doDelete($criteria, $con);
    1675:             ContentAssocPeer::clearRelatedInstancePool();
    1676:             $con->commit();
    1677:
    1678:             return $affectedRows;
    1679:         } catch (PropelException $e) {
    1680:             $con->rollBack();
    1681:             throw $e;
    1682:         }
    1683:     }
    1684:
    1685:     /**
    1686:      * Validates all modified columns of given ContentAssoc object.
    1687:      * If parameter $columns is either a single column name or an array of column names
    1688:      * than only those columns are validated.
    1689:      *
    1690:      * NOTICE: This does not apply to primary or foreign keys for now.
    1691:      *
    1692:      * @param      ContentAssoc $obj The object to validate.
    1693:      * @param      mixed $cols Column name or array of column names.
    1694:      *
    1695:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
    1696:      */
    1697:     public static function doValidate($obj, $cols = null)
    1698:     {
    1699:         $columns = array();
    1700:
    1701:         if ($cols) {
    1702:             $dbMap = Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME);
    1703:             $tableMap = $dbMap->getTable(ContentAssocPeer::TABLE_NAME);
    1704:
    1705:             if (! is_array($cols)) {
    1706:                 $cols = array($cols);
    1707:             }
    1708:
    1709:             foreach ($cols as $colName) {
    1710:                 if ($tableMap->hasColumn($colName)) {
    1711:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
    1712:                     $columns[$colName] = $obj->$get();
    1713:                 }
    1714:             }
    1715:         } else {
    1716:
    1717:         }
    1718:
    1719:         return BasePeer::doValidate(ContentAssocPeer::DATABASE_NAME, ContentAssocPeer::TABLE_NAME, $columns);
    1720:     }
    1721:
    1722:     /**
    1723:      * Retrieve a single object by pkey.
    1724:      *
    1725:      * @param      int $pk the primary key.
    1726:      * @param      PropelPDO $con the connection to use
    1727:      * @return ContentAssoc
    1728:      */
    1729:     public static function retrieveByPK($pk, PropelPDO $con = null)
    1730:     {
    1731:
    1732:         if (null !== ($obj = ContentAssocPeer::getInstanceFromPool((string) $pk))) {
    1733:             return $obj;
    1734:         }
    1735:
    1736:         if ($con === null) {
    1737:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1738:         }
    1739:
    1740:         $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
    1741:         $criteria->add(ContentAssocPeer::ID, $pk);
    1742:
    1743:         $v = ContentAssocPeer::doSelect($criteria, $con);
    1744:
    1745:         return !empty($v) > 0 ? $v[0] : null;
    1746:     }
    1747:
    1748:     /**
    1749:      * Retrieve multiple objects by pkey.
    1750:      *
    1751:      * @param      array $pks List of primary keys
    1752:      * @param      PropelPDO $con the connection to use
    1753:      * @return ContentAssoc[]
    1754:      * @throws PropelException Any exceptions caught during processing will be
    1755:      *       rethrown wrapped into a PropelException.
    1756:      */
    1757:     public static function retrieveByPKs($pks, PropelPDO $con = null)
    1758:     {
    1759:         if ($con === null) {
    1760:             $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1761:         }
    1762:
    1763:         $objs = null;
    1764:         if (empty($pks)) {
    1765:             $objs = array();
    1766:         } else {
    1767:             $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME);
    1768:             $criteria->add(ContentAssocPeer::ID, $pks, Criteria::IN);
    1769:             $objs = ContentAssocPeer::doSelect($criteria, $con);
    1770:         }
    1771:
    1772:         return $objs;
    1773:     }
    1774:
    1775: } // BaseContentAssocPeer
    1776:
    1777: // This is the static code needed to register the TableMap for this table with the main Propel class.
    1778: //
    1779: BaseContentAssocPeer::buildTableMap();
    1780:
    1781: