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