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

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