# File core/lib/Thelia/Model/om/BaseGroupResourcePeer.php | thelia

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