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