       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\CouponOrderPeer;
      13: use Thelia\Model\CurrencyPeer;
      14: use Thelia\Model\CustomerPeer;
      15: use Thelia\Model\Order;
      16: use Thelia\Model\OrderAddressPeer;
      17: use Thelia\Model\OrderPeer;
      18: use Thelia\Model\OrderProductPeer;
      19: use Thelia\Model\OrderStatusPeer;
      20: use Thelia\Model\map\OrderTableMap;
      21:
      22: /**
      23:  * Base static class for performing query and update operations on the 'order' table.
      24:  *
      25:  *
      26:  *
      27:  * @package propel.generator.Thelia.Model.om
      28:  */
      29: abstract class BaseOrderPeer
      30: {
      31:
      32:     /** the default database name for this class */
      33:     const DATABASE_NAME = 'thelia';
      34:
      35:     /** the table name for this class */
      36:     const TABLE_NAME = 'order';
      37:
      38:     /** the related Propel class for this table */
      39:     const OM_CLASS = 'Thelia\\Model\\Order';
      40:
      41:     /** the related TableMap class for this table */
      42:     const TM_CLASS = 'OrderTableMap';
      43:
      44:     /** The total number of columns. */
      45:     const NUM_COLUMNS = 18;
      46:
      47:     /** The number of lazy-loaded columns. */
      48:     const NUM_LAZY_LOAD_COLUMNS = 0;
      49:
      50:     /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
      51:     const NUM_HYDRATE_COLUMNS = 18;
      52:
      53:     /** the column name for the id field */
      54:     const ID = 'order.id';
      55:
      56:     /** the column name for the ref field */
      57:     const REF = 'order.ref';
      58:
      59:     /** the column name for the customer_id field */
      60:     const CUSTOMER_ID = 'order.customer_id';
      61:
      62:     /** the column name for the address_invoice field */
      63:     const ADDRESS_INVOICE = 'order.address_invoice';
      64:
      65:     /** the column name for the address_delivery field */
      66:     const ADDRESS_DELIVERY = 'order.address_delivery';
      67:
      68:     /** the column name for the invoice_date field */
      69:     const INVOICE_DATE = 'order.invoice_date';
      70:
      71:     /** the column name for the currency_id field */
      72:     const CURRENCY_ID = 'order.currency_id';
      73:
      74:     /** the column name for the currency_rate field */
      75:     const CURRENCY_RATE = 'order.currency_rate';
      76:
      77:     /** the column name for the transaction field */
      78:     const TRANSACTION = 'order.transaction';
      79:
      80:     /** the column name for the delivery_num field */
      81:     const DELIVERY_NUM = 'order.delivery_num';
      82:
      83:     /** the column name for the invoice field */
      84:     const INVOICE = 'order.invoice';
      85:
      86:     /** the column name for the postage field */
      87:     const POSTAGE = 'order.postage';
      88:
      89:     /** the column name for the payment field */
      90:     const PAYMENT = 'order.payment';
      91:
      92:     /** the column name for the carrier field */
      93:     const CARRIER = 'order.carrier';
      94:
      95:     /** the column name for the status_id field */
      96:     const STATUS_ID = 'order.status_id';
      97:
      98:     /** the column name for the lang field */
      99:     const LANG = 'order.lang';
     100:
     101:     /** the column name for the created_at field */
     102:     const CREATED_AT = 'order.created_at';
     103:
     104:     /** the column name for the updated_at field */
     105:     const UPDATED_AT = 'order.updated_at';
     106:
     107:     /** The default string format for model objects of the related table **/
     108:     const DEFAULT_STRING_FORMAT = 'YAML';
     109:
     110:     /**
     111:      * An identiy map to hold any loaded instances of Order objects.
     112:      * This must be public so that other peer classes can access this when hydrating from JOIN
     113:      * queries.
     114:      * @var        array Order[]
     115:      */
     116:     public static $instances = array();
     117:
     118:
     119:     /**
     120:      * holds an array of fieldnames
     121:      *
     122:      * first dimension keys are the type constants
     123:      * e.g. OrderPeer::$fieldNames[OrderPeer::TYPE_PHPNAME][0] = 'Id'
     124:      */
     125:     protected static $fieldNames = array (
     126:         BasePeer::TYPE_PHPNAME => array ('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ),
     127:         BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ),
     128:         BasePeer::TYPE_COLNAME => array (OrderPeer::ID, OrderPeer::REF, OrderPeer::CUSTOMER_ID, OrderPeer::ADDRESS_INVOICE, OrderPeer::ADDRESS_DELIVERY, OrderPeer::INVOICE_DATE, OrderPeer::CURRENCY_ID, OrderPeer::CURRENCY_RATE, OrderPeer::TRANSACTION, OrderPeer::DELIVERY_NUM, OrderPeer::INVOICE, OrderPeer::POSTAGE, OrderPeer::PAYMENT, OrderPeer::CARRIER, OrderPeer::STATUS_ID, OrderPeer::LANG, OrderPeer::CREATED_AT, OrderPeer::UPDATED_AT, ),
     129:         BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ),
     130:         BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ),
     131:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
     132:     );
     133:
     134:     /**
     135:      * holds an array of keys for quick access to the fieldnames array
     136:      *
     137:      * first dimension keys are the type constants
     138:      * e.g. OrderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
     139:      */
     140:     protected static $fieldKeys = array (
     141:         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
     142:         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
     143:         BasePeer::TYPE_COLNAME => array (OrderPeer::ID => 0, OrderPeer::REF => 1, OrderPeer::CUSTOMER_ID => 2, OrderPeer::ADDRESS_INVOICE => 3, OrderPeer::ADDRESS_DELIVERY => 4, OrderPeer::INVOICE_DATE => 5, OrderPeer::CURRENCY_ID => 6, OrderPeer::CURRENCY_RATE => 7, OrderPeer::TRANSACTION => 8, OrderPeer::DELIVERY_NUM => 9, OrderPeer::INVOICE => 10, OrderPeer::POSTAGE => 11, OrderPeer::PAYMENT => 12, OrderPeer::CARRIER => 13, OrderPeer::STATUS_ID => 14, OrderPeer::LANG => 15, OrderPeer::CREATED_AT => 16, OrderPeer::UPDATED_AT => 17, ),
     144:         BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
     145:         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ),
     146:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
     147:     );
     148:
     149:     /**
     150:      * Translates a fieldname to another type
     151:      *
     152:      * @param      string $name field name
     153:      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     154:      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     155:      * @param      string $toType   One of the class type constants
     156:      * @return string          translated name of the field.
     157:      * @throws PropelException - if the specified name could not be found in the fieldname mappings.
     158:      */
     159:     public static function translateFieldName($name, $fromType, $toType)
     160:     {
     161:         $toNames = OrderPeer::getFieldNames($toType);
     162:         $key = isset(OrderPeer::$fieldKeys[$fromType][$name]) ? OrderPeer::$fieldKeys[$fromType][$name] : null;
     163:         if ($key === null) {
     164:             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderPeer::$fieldKeys[$fromType], true));
     165:         }
     166:
     167:         return $toNames[$key];
     168:     }
     169:
     170:     /**
     171:      * Returns an array of field names.
     172:      *
     173:      * @param      string $type The type of fieldnames to return:
     174:      *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     175:      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     176:      * @return array           A list of field names
     177:      * @throws PropelException - if the type is not valid.
     178:      */
     179:     public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
     180:     {
     181:         if (!array_key_exists($type, OrderPeer::$fieldNames)) {
     182:             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.');
     183:         }
     184:
     185:         return OrderPeer::$fieldNames[$type];
     186:     }
     187:
     188:     /**
     189:      * Convenience method which changes table.column to alias.column.
     190:      *
     191:      * Using this method you can maintain SQL abstraction while using column aliases.
     192:      * <code>
     193:      *      $c->addAlias("alias1", TablePeer::TABLE_NAME);
     194:      *      $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
     195:      * </code>
     196:      * @param      string $alias The alias for the current table.
     197:      * @param      string $column The column name for current table. (i.e. OrderPeer::COLUMN_NAME).
     198:      * @return string
     199:      */
     200:     public static function alias($alias, $column)
     201:     {
     202:         return str_replace(OrderPeer::TABLE_NAME.'.', $alias.'.', $column);
     203:     }
     204:
     205:     /**
     206:      * Add all the columns needed to create a new object.
     207:      *
     208:      * Note: any columns that were marked with lazyLoad="true" in the
     209:      * XML schema will not be added to the select list and only loaded
     210:      * on demand.
     211:      *
     212:      * @param      Criteria $criteria object containing the columns to add.
     213:      * @param      string   $alias    optional table alias
     214:      * @throws PropelException Any exceptions caught during processing will be
     215:      *       rethrown wrapped into a PropelException.
     216:      */
     217:     public static function addSelectColumns(Criteria $criteria, $alias = null)
     218:     {
     219:         if (null === $alias) {
     220:             $criteria->addSelectColumn(OrderPeer::ID);
     221:             $criteria->addSelectColumn(OrderPeer::REF);
     222:             $criteria->addSelectColumn(OrderPeer::CUSTOMER_ID);
     223:             $criteria->addSelectColumn(OrderPeer::ADDRESS_INVOICE);
     224:             $criteria->addSelectColumn(OrderPeer::ADDRESS_DELIVERY);
     225:             $criteria->addSelectColumn(OrderPeer::INVOICE_DATE);
     226:             $criteria->addSelectColumn(OrderPeer::CURRENCY_ID);
     227:             $criteria->addSelectColumn(OrderPeer::CURRENCY_RATE);
     228:             $criteria->addSelectColumn(OrderPeer::TRANSACTION);
     229:             $criteria->addSelectColumn(OrderPeer::DELIVERY_NUM);
     230:             $criteria->addSelectColumn(OrderPeer::INVOICE);
     231:             $criteria->addSelectColumn(OrderPeer::POSTAGE);
     232:             $criteria->addSelectColumn(OrderPeer::PAYMENT);
     233:             $criteria->addSelectColumn(OrderPeer::CARRIER);
     234:             $criteria->addSelectColumn(OrderPeer::STATUS_ID);
     235:             $criteria->addSelectColumn(OrderPeer::LANG);
     236:             $criteria->addSelectColumn(OrderPeer::CREATED_AT);
     237:             $criteria->addSelectColumn(OrderPeer::UPDATED_AT);
     238:         } else {
     239:             $criteria->addSelectColumn($alias . '.id');
     240:             $criteria->addSelectColumn($alias . '.ref');
     241:             $criteria->addSelectColumn($alias . '.customer_id');
     242:             $criteria->addSelectColumn($alias . '.address_invoice');
     243:             $criteria->addSelectColumn($alias . '.address_delivery');
     244:             $criteria->addSelectColumn($alias . '.invoice_date');
     245:             $criteria->addSelectColumn($alias . '.currency_id');
     246:             $criteria->addSelectColumn($alias . '.currency_rate');
     247:             $criteria->addSelectColumn($alias . '.transaction');
     248:             $criteria->addSelectColumn($alias . '.delivery_num');
     249:             $criteria->addSelectColumn($alias . '.invoice');
     250:             $criteria->addSelectColumn($alias . '.postage');
     251:             $criteria->addSelectColumn($alias . '.payment');
     252:             $criteria->addSelectColumn($alias . '.carrier');
     253:             $criteria->addSelectColumn($alias . '.status_id');
     254:             $criteria->addSelectColumn($alias . '.lang');
     255:             $criteria->addSelectColumn($alias . '.created_at');
     256:             $criteria->addSelectColumn($alias . '.updated_at');
     257:         }
     258:     }
     259:
     260:     /**
     261:      * Returns the number of rows matching criteria.
     262:      *
     263:      * @param      Criteria $criteria
     264:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     265:      * @param      PropelPDO $con
     266:      * @return int Number of matching rows.
     267:      */
     268:     public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
     269:     {
     270:         // we may modify criteria, so copy it first
     271:         $criteria = clone $criteria;
     272:
     273:         // We need to set the primary table name, since in the case that there are no WHERE columns
     274:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     275:         // tables go into the FROM clause.
     276:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     277:
     278:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     279:             $criteria->setDistinct();
     280:         }
     281:
     282:         if (!$criteria->hasSelectClause()) {
     283:             OrderPeer::addSelectColumns($criteria);
     284:         }
     285:
     286:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     287:         $criteria->setDbName(OrderPeer::DATABASE_NAME); // Set the correct dbName
     288:
     289:         if ($con === null) {
     290:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     291:         }
     292:         // BasePeer returns a PDOStatement
     293:         $stmt = BasePeer::doCount($criteria, $con);
     294:
     295:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     296:             $count = (int) $row[0];
     297:         } else {
     298:             $count = 0; // no rows returned; we infer that means 0 matches.
     299:         }
     300:         $stmt->closeCursor();
     301:
     302:         return $count;
     303:     }
     304:     /**
     305:      * Selects one object from the DB.
     306:      *
     307:      * @param      Criteria $criteria object used to create the SELECT statement.
     308:      * @param      PropelPDO $con
     309:      * @return                 Order
     310:      * @throws PropelException Any exceptions caught during processing will be
     311:      *       rethrown wrapped into a PropelException.
     312:      */
     313:     public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
     314:     {
     315:         $critcopy = clone $criteria;
     316:         $critcopy->setLimit(1);
     317:         $objects = OrderPeer::doSelect($critcopy, $con);
     318:         if ($objects) {
     319:             return $objects[0];
     320:         }
     321:
     322:         return null;
     323:     }
     324:     /**
     325:      * Selects several row from the DB.
     326:      *
     327:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     328:      * @param      PropelPDO $con
     329:      * @return array           Array of selected Objects
     330:      * @throws PropelException Any exceptions caught during processing will be
     331:      *       rethrown wrapped into a PropelException.
     332:      */
     333:     public static function doSelect(Criteria $criteria, PropelPDO $con = null)
     334:     {
     335:         return OrderPeer::populateObjects(OrderPeer::doSelectStmt($criteria, $con));
     336:     }
     337:     /**
     338:      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
     339:      *
     340:      * Use this method directly if you want to work with an executed statement directly (for example
     341:      * to perform your own object hydration).
     342:      *
     343:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     344:      * @param      PropelPDO $con The connection to use
     345:      * @throws PropelException Any exceptions caught during processing will be
     346:      *       rethrown wrapped into a PropelException.
     347:      * @return PDOStatement The executed PDOStatement object.
     348:      * @see        BasePeer::doSelect()
     349:      */
     350:     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
     351:     {
     352:         if ($con === null) {
     353:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     354:         }
     355:
     356:         if (!$criteria->hasSelectClause()) {
     357:             $criteria = clone $criteria;
     358:             OrderPeer::addSelectColumns($criteria);
     359:         }
     360:
     361:         // Set the correct dbName
     362:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     363:
     364:         // BasePeer returns a PDOStatement
     365:         return BasePeer::doSelect($criteria, $con);
     366:     }
     367:     /**
     368:      * Adds an object to the instance pool.
     369:      *
     370:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
     371:      * from the database.  In some cases -- especially when you override doSelect*()
     372:      * methods in your stub classes -- you may need to explicitly add objects
     373:      * to the cache in order to ensure that the same objects are always returned by doSelect*()
     374:      * and retrieveByPK*() calls.
     375:      *
     376:      * @param      Order $obj A Order object.
     377:      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
     378:      */
     379:     public static function addInstanceToPool($obj, $key = null)
     380:     {
     381:         if (Propel::isInstancePoolingEnabled()) {
     382:             if ($key === null) {
     383:                 $key = (string) $obj->getId();
     384:             } // if key === null
     385:             OrderPeer::$instances[$key] = $obj;
     386:         }
     387:     }
     388:
     389:     /**
     390:      * Removes an object from the instance pool.
     391:      *
     392:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
     393:      * from the database.  In some cases -- especially when you override doDelete
     394:      * methods in your stub classes -- you may need to explicitly remove objects
     395:      * from the cache in order to prevent returning objects that no longer exist.
     396:      *
     397:      * @param      mixed $value A Order object or a primary key value.
     398:      *
     399:      * @return void
     400:      * @throws PropelException - if the value is invalid.
     401:      */
     402:     public static function removeInstanceFromPool($value)
     403:     {
     404:         if (Propel::isInstancePoolingEnabled() && $value !== null) {
     405:             if (is_object($value) && $value instanceof Order) {
     406:                 $key = (string) $value->getId();
     407:             } elseif (is_scalar($value)) {
     408:                 // assume we've been passed a primary key
     409:                 $key = (string) $value;
     410:             } else {
     411:                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Order object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
     412:                 throw $e;
     413:             }
     414:
     415:             unset(OrderPeer::$instances[$key]);
     416:         }
     417:     } // removeInstanceFromPool()
     418:
     419:     /**
     420:      * 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.
     421:      *
     422:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     423:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
     424:      *
     425:      * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
     426:      * @return   Order Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
     427:      * @see        getPrimaryKeyHash()
     428:      */
     429:     public static function getInstanceFromPool($key)
     430:     {
     431:         if (Propel::isInstancePoolingEnabled()) {
     432:             if (isset(OrderPeer::$instances[$key])) {
     433:                 return OrderPeer::$instances[$key];
     434:             }
     435:         }
     436:
     437:         return null; // just to be explicit
     438:     }
     439:
     440:     /**
     441:      * Clear the instance pool.
     442:      *
     443:      * @return void
     444:      */
     445:     public static function clearInstancePool($and_clear_all_references = false)
     446:     {
     447:       if ($and_clear_all_references)
     448:       {
     449:         foreach (OrderPeer::$instances as $instance)
     450:         {
     451:           $instance->clearAllReferences(true);
     452:         }
     453:       }
     454:         OrderPeer::$instances = array();
     455:     }
     456:
     457:     /**
     458:      * Method to invalidate the instance pool of all tables related to order
     459:      * by a foreign key with ON DELETE CASCADE
     460:      */
     461:     public static function clearRelatedInstancePool()
     462:     {
     463:         // Invalidate objects in OrderProductPeer instance pool,
     464:         // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     465:         OrderProductPeer::clearInstancePool();
     466:         // Invalidate objects in CouponOrderPeer instance pool,
     467:         // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
     468:         CouponOrderPeer::clearInstancePool();
     469:     }
     470:
     471:     /**
     472:      * 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.
     473:      *
     474:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     475:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
     476:      *
     477:      * @param      array $row PropelPDO resultset row.
     478:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     479:      * @return string A string version of PK or null if the components of primary key in result array are all null.
     480:      */
     481:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
     482:     {
     483:         // If the PK cannot be derived from the row, return null.
     484:         if ($row[$startcol] === null) {
     485:             return null;
     486:         }
     487:
     488:         return (string) $row[$startcol];
     489:     }
     490:
     491:     /**
     492:      * Retrieves the primary key from the DB resultset row
     493:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     494:      * a multi-column primary key, an array of the primary key columns will be returned.
     495:      *
     496:      * @param      array $row PropelPDO resultset row.
     497:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     498:      * @return mixed The primary key of the row
     499:      */
     500:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
     501:     {
     502:
     503:         return (int) $row[$startcol];
     504:     }
     505:
     506:     /**
     507:      * The returned array will contain objects of the default type or
     508:      * objects that inherit from the default.
     509:      *
     510:      * @throws PropelException Any exceptions caught during processing will be
     511:      *       rethrown wrapped into a PropelException.
     512:      */
     513:     public static function populateObjects(PDOStatement $stmt)
     514:     {
     515:         $results = array();
     516:
     517:         // set the class once to avoid overhead in the loop
     518:         $cls = OrderPeer::getOMClass();
     519:         // populate the object(s)
     520:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     521:             $key = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
     522:             if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) {
     523:                 // We no longer rehydrate the object, since this can cause data loss.
     524:                 // See http://www.propelorm.org/ticket/509
     525:                 // $obj->hydrate($row, 0, true); // rehydrate
     526:                 $results[] = $obj;
     527:             } else {
     528:                 $obj = new $cls();
     529:                 $obj->hydrate($row);
     530:                 $results[] = $obj;
     531:                 OrderPeer::addInstanceToPool($obj, $key);
     532:             } // if key exists
     533:         }
     534:         $stmt->closeCursor();
     535:
     536:         return $results;
     537:     }
     538:     /**
     539:      * Populates an object of the default type or an object that inherit from the default.
     540:      *
     541:      * @param      array $row PropelPDO resultset row.
     542:      * @param      int $startcol The 0-based offset for reading from the resultset row.
     543:      * @throws PropelException Any exceptions caught during processing will be
     544:      *       rethrown wrapped into a PropelException.
     545:      * @return array (Order object, last column rank)
     546:      */
     547:     public static function populateObject($row, $startcol = 0)
     548:     {
     549:         $key = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol);
     550:         if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) {
     551:             // We no longer rehydrate the object, since this can cause data loss.
     552:             // See http://www.propelorm.org/ticket/509
     553:             // $obj->hydrate($row, $startcol, true); // rehydrate
     554:             $col = $startcol + OrderPeer::NUM_HYDRATE_COLUMNS;
     555:         } else {
     556:             $cls = OrderPeer::OM_CLASS;
     557:             $obj = new $cls();
     558:             $col = $obj->hydrate($row, $startcol);
     559:             OrderPeer::addInstanceToPool($obj, $key);
     560:         }
     561:
     562:         return array($obj, $col);
     563:     }
     564:
     565:
     566:     /**
     567:      * Returns the number of rows matching criteria, joining the related Currency table
     568:      *
     569:      * @param      Criteria $criteria
     570:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     571:      * @param      PropelPDO $con
     572:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     573:      * @return int Number of matching rows.
     574:      */
     575:     public static function doCountJoinCurrency(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     576:     {
     577:         // we're going to modify criteria, so copy it first
     578:         $criteria = clone $criteria;
     579:
     580:         // We need to set the primary table name, since in the case that there are no WHERE columns
     581:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     582:         // tables go into the FROM clause.
     583:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     584:
     585:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     586:             $criteria->setDistinct();
     587:         }
     588:
     589:         if (!$criteria->hasSelectClause()) {
     590:             OrderPeer::addSelectColumns($criteria);
     591:         }
     592:
     593:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     594:
     595:         // Set the correct dbName
     596:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     597:
     598:         if ($con === null) {
     599:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     600:         }
     601:
     602:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
     603:
     604:         $stmt = BasePeer::doCount($criteria, $con);
     605:
     606:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     607:             $count = (int) $row[0];
     608:         } else {
     609:             $count = 0; // no rows returned; we infer that means 0 matches.
     610:         }
     611:         $stmt->closeCursor();
     612:
     613:         return $count;
     614:     }
     615:
     616:
     617:     /**
     618:      * Returns the number of rows matching criteria, joining the related Customer table
     619:      *
     620:      * @param      Criteria $criteria
     621:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     622:      * @param      PropelPDO $con
     623:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     624:      * @return int Number of matching rows.
     625:      */
     626:     public static function doCountJoinCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     627:     {
     628:         // we're going to modify criteria, so copy it first
     629:         $criteria = clone $criteria;
     630:
     631:         // We need to set the primary table name, since in the case that there are no WHERE columns
     632:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     633:         // tables go into the FROM clause.
     634:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     635:
     636:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     637:             $criteria->setDistinct();
     638:         }
     639:
     640:         if (!$criteria->hasSelectClause()) {
     641:             OrderPeer::addSelectColumns($criteria);
     642:         }
     643:
     644:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     645:
     646:         // Set the correct dbName
     647:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     648:
     649:         if ($con === null) {
     650:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     651:         }
     652:
     653:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
     654:
     655:         $stmt = BasePeer::doCount($criteria, $con);
     656:
     657:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     658:             $count = (int) $row[0];
     659:         } else {
     660:             $count = 0; // no rows returned; we infer that means 0 matches.
     661:         }
     662:         $stmt->closeCursor();
     663:
     664:         return $count;
     665:     }
     666:
     667:
     668:     /**
     669:      * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table
     670:      *
     671:      * @param      Criteria $criteria
     672:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     673:      * @param      PropelPDO $con
     674:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     675:      * @return int Number of matching rows.
     676:      */
     677:     public static function doCountJoinOrderAddressRelatedByAddressInvoice(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     678:     {
     679:         // we're going to modify criteria, so copy it first
     680:         $criteria = clone $criteria;
     681:
     682:         // We need to set the primary table name, since in the case that there are no WHERE columns
     683:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     684:         // tables go into the FROM clause.
     685:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     686:
     687:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     688:             $criteria->setDistinct();
     689:         }
     690:
     691:         if (!$criteria->hasSelectClause()) {
     692:             OrderPeer::addSelectColumns($criteria);
     693:         }
     694:
     695:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     696:
     697:         // Set the correct dbName
     698:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     699:
     700:         if ($con === null) {
     701:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     702:         }
     703:
     704:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
     705:
     706:         $stmt = BasePeer::doCount($criteria, $con);
     707:
     708:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     709:             $count = (int) $row[0];
     710:         } else {
     711:             $count = 0; // no rows returned; we infer that means 0 matches.
     712:         }
     713:         $stmt->closeCursor();
     714:
     715:         return $count;
     716:     }
     717:
     718:
     719:     /**
     720:      * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table
     721:      *
     722:      * @param      Criteria $criteria
     723:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     724:      * @param      PropelPDO $con
     725:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     726:      * @return int Number of matching rows.
     727:      */
     728:     public static function doCountJoinOrderAddressRelatedByAddressDelivery(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     729:     {
     730:         // we're going to modify criteria, so copy it first
     731:         $criteria = clone $criteria;
     732:
     733:         // We need to set the primary table name, since in the case that there are no WHERE columns
     734:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     735:         // tables go into the FROM clause.
     736:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     737:
     738:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     739:             $criteria->setDistinct();
     740:         }
     741:
     742:         if (!$criteria->hasSelectClause()) {
     743:             OrderPeer::addSelectColumns($criteria);
     744:         }
     745:
     746:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     747:
     748:         // Set the correct dbName
     749:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     750:
     751:         if ($con === null) {
     752:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     753:         }
     754:
     755:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
     756:
     757:         $stmt = BasePeer::doCount($criteria, $con);
     758:
     759:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     760:             $count = (int) $row[0];
     761:         } else {
     762:             $count = 0; // no rows returned; we infer that means 0 matches.
     763:         }
     764:         $stmt->closeCursor();
     765:
     766:         return $count;
     767:     }
     768:
     769:
     770:     /**
     771:      * Returns the number of rows matching criteria, joining the related OrderStatus table
     772:      *
     773:      * @param      Criteria $criteria
     774:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     775:      * @param      PropelPDO $con
     776:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     777:      * @return int Number of matching rows.
     778:      */
     779:     public static function doCountJoinOrderStatus(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
     780:     {
     781:         // we're going to modify criteria, so copy it first
     782:         $criteria = clone $criteria;
     783:
     784:         // We need to set the primary table name, since in the case that there are no WHERE columns
     785:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
     786:         // tables go into the FROM clause.
     787:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
     788:
     789:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
     790:             $criteria->setDistinct();
     791:         }
     792:
     793:         if (!$criteria->hasSelectClause()) {
     794:             OrderPeer::addSelectColumns($criteria);
     795:         }
     796:
     797:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
     798:
     799:         // Set the correct dbName
     800:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
     801:
     802:         if ($con === null) {
     803:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     804:         }
     805:
     806:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
     807:
     808:         $stmt = BasePeer::doCount($criteria, $con);
     809:
     810:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     811:             $count = (int) $row[0];
     812:         } else {
     813:             $count = 0; // no rows returned; we infer that means 0 matches.
     814:         }
     815:         $stmt->closeCursor();
     816:
     817:         return $count;
     818:     }
     819:
     820:
     821:     /**
     822:      * Selects a collection of Order objects pre-filled with their Currency objects.
     823:      * @param      Criteria  $criteria
     824:      * @param      PropelPDO $con
     825:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     826:      * @return array           Array of Order objects.
     827:      * @throws PropelException Any exceptions caught during processing will be
     828:      *       rethrown wrapped into a PropelException.
     829:      */
     830:     public static function doSelectJoinCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     831:     {
     832:         $criteria = clone $criteria;
     833:
     834:         // Set the correct dbName if it has not been overridden
     835:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     836:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
     837:         }
     838:
     839:         OrderPeer::addSelectColumns($criteria);
     840:         $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
     841:         CurrencyPeer::addSelectColumns($criteria);
     842:
     843:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
     844:
     845:         $stmt = BasePeer::doSelect($criteria, $con);
     846:         $results = array();
     847:
     848:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     849:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
     850:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
     851:                 // We no longer rehydrate the object, since this can cause data loss.
     852:                 // See http://www.propelorm.org/ticket/509
     853:                 // $obj1->hydrate($row, 0, true); // rehydrate
     854:             } else {
     855:
     856:                 $cls = OrderPeer::getOMClass();
     857:
     858:                 $obj1 = new $cls();
     859:                 $obj1->hydrate($row);
     860:                 OrderPeer::addInstanceToPool($obj1, $key1);
     861:             } // if $obj1 already loaded
     862:
     863:             $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol);
     864:             if ($key2 !== null) {
     865:                 $obj2 = CurrencyPeer::getInstanceFromPool($key2);
     866:                 if (!$obj2) {
     867:
     868:                     $cls = CurrencyPeer::getOMClass();
     869:
     870:                     $obj2 = new $cls();
     871:                     $obj2->hydrate($row, $startcol);
     872:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
     873:                 } // if obj2 already loaded
     874:
     875:                 // Add the $obj1 (Order) to $obj2 (Currency)
     876:                 $obj2->addOrder($obj1);
     877:
     878:             } // if joined row was not null
     879:
     880:             $results[] = $obj1;
     881:         }
     882:         $stmt->closeCursor();
     883:
     884:         return $results;
     885:     }
     886:
     887:
     888:     /**
     889:      * Selects a collection of Order objects pre-filled with their Customer objects.
     890:      * @param      Criteria  $criteria
     891:      * @param      PropelPDO $con
     892:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     893:      * @return array           Array of Order objects.
     894:      * @throws PropelException Any exceptions caught during processing will be
     895:      *       rethrown wrapped into a PropelException.
     896:      */
     897:     public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     898:     {
     899:         $criteria = clone $criteria;
     900:
     901:         // Set the correct dbName if it has not been overridden
     902:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     903:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
     904:         }
     905:
     906:         OrderPeer::addSelectColumns($criteria);
     907:         $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
     908:         CustomerPeer::addSelectColumns($criteria);
     909:
     910:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
     911:
     912:         $stmt = BasePeer::doSelect($criteria, $con);
     913:         $results = array();
     914:
     915:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     916:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
     917:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
     918:                 // We no longer rehydrate the object, since this can cause data loss.
     919:                 // See http://www.propelorm.org/ticket/509
     920:                 // $obj1->hydrate($row, 0, true); // rehydrate
     921:             } else {
     922:
     923:                 $cls = OrderPeer::getOMClass();
     924:
     925:                 $obj1 = new $cls();
     926:                 $obj1->hydrate($row);
     927:                 OrderPeer::addInstanceToPool($obj1, $key1);
     928:             } // if $obj1 already loaded
     929:
     930:             $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol);
     931:             if ($key2 !== null) {
     932:                 $obj2 = CustomerPeer::getInstanceFromPool($key2);
     933:                 if (!$obj2) {
     934:
     935:                     $cls = CustomerPeer::getOMClass();
     936:
     937:                     $obj2 = new $cls();
     938:                     $obj2->hydrate($row, $startcol);
     939:                     CustomerPeer::addInstanceToPool($obj2, $key2);
     940:                 } // if obj2 already loaded
     941:
     942:                 // Add the $obj1 (Order) to $obj2 (Customer)
     943:                 $obj2->addOrder($obj1);
     944:
     945:             } // if joined row was not null
     946:
     947:             $results[] = $obj1;
     948:         }
     949:         $stmt->closeCursor();
     950:
     951:         return $results;
     952:     }
     953:
     954:
     955:     /**
     956:      * Selects a collection of Order objects pre-filled with their OrderAddress objects.
     957:      * @param      Criteria  $criteria
     958:      * @param      PropelPDO $con
     959:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     960:      * @return array           Array of Order objects.
     961:      * @throws PropelException Any exceptions caught during processing will be
     962:      *       rethrown wrapped into a PropelException.
     963:      */
     964:     public static function doSelectJoinOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     965:     {
     966:         $criteria = clone $criteria;
     967:
     968:         // Set the correct dbName if it has not been overridden
     969:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
     970:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
     971:         }
     972:
     973:         OrderPeer::addSelectColumns($criteria);
     974:         $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
     975:         OrderAddressPeer::addSelectColumns($criteria);
     976:
     977:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
     978:
     979:         $stmt = BasePeer::doSelect($criteria, $con);
     980:         $results = array();
     981:
     982:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     983:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
     984:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
     985:                 // We no longer rehydrate the object, since this can cause data loss.
     986:                 // See http://www.propelorm.org/ticket/509
     987:                 // $obj1->hydrate($row, 0, true); // rehydrate
     988:             } else {
     989:
     990:                 $cls = OrderPeer::getOMClass();
     991:
     992:                 $obj1 = new $cls();
     993:                 $obj1->hydrate($row);
     994:                 OrderPeer::addInstanceToPool($obj1, $key1);
     995:             } // if $obj1 already loaded
     996:
     997:             $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
     998:             if ($key2 !== null) {
     999:                 $obj2 = OrderAddressPeer::getInstanceFromPool($key2);
    1000:                 if (!$obj2) {
    1001:
    1002:                     $cls = OrderAddressPeer::getOMClass();
    1003:
    1004:                     $obj2 = new $cls();
    1005:                     $obj2->hydrate($row, $startcol);
    1006:                     OrderAddressPeer::addInstanceToPool($obj2, $key2);
    1007:                 } // if obj2 already loaded
    1008:
    1009:                 // Add the $obj1 (Order) to $obj2 (OrderAddress)
    1010:                 $obj2->addOrderRelatedByAddressInvoice($obj1);
    1011:
    1012:             } // if joined row was not null
    1013:
    1014:             $results[] = $obj1;
    1015:         }
    1016:         $stmt->closeCursor();
    1017:
    1018:         return $results;
    1019:     }
    1020:
    1021:
    1022:     /**
    1023:      * Selects a collection of Order objects pre-filled with their OrderAddress objects.
    1024:      * @param      Criteria  $criteria
    1025:      * @param      PropelPDO $con
    1026:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1027:      * @return array           Array of Order objects.
    1028:      * @throws PropelException Any exceptions caught during processing will be
    1029:      *       rethrown wrapped into a PropelException.
    1030:      */
    1031:     public static function doSelectJoinOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1032:     {
    1033:         $criteria = clone $criteria;
    1034:
    1035:         // Set the correct dbName if it has not been overridden
    1036:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1037:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1038:         }
    1039:
    1040:         OrderPeer::addSelectColumns($criteria);
    1041:         $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
    1042:         OrderAddressPeer::addSelectColumns($criteria);
    1043:
    1044:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1045:
    1046:         $stmt = BasePeer::doSelect($criteria, $con);
    1047:         $results = array();
    1048:
    1049:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1050:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1051:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1052:                 // We no longer rehydrate the object, since this can cause data loss.
    1053:                 // See http://www.propelorm.org/ticket/509
    1054:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1055:             } else {
    1056:
    1057:                 $cls = OrderPeer::getOMClass();
    1058:
    1059:                 $obj1 = new $cls();
    1060:                 $obj1->hydrate($row);
    1061:                 OrderPeer::addInstanceToPool($obj1, $key1);
    1062:             } // if $obj1 already loaded
    1063:
    1064:             $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol);
    1065:             if ($key2 !== null) {
    1066:                 $obj2 = OrderAddressPeer::getInstanceFromPool($key2);
    1067:                 if (!$obj2) {
    1068:
    1069:                     $cls = OrderAddressPeer::getOMClass();
    1070:
    1071:                     $obj2 = new $cls();
    1072:                     $obj2->hydrate($row, $startcol);
    1073:                     OrderAddressPeer::addInstanceToPool($obj2, $key2);
    1074:                 } // if obj2 already loaded
    1075:
    1076:                 // Add the $obj1 (Order) to $obj2 (OrderAddress)
    1077:                 $obj2->addOrderRelatedByAddressDelivery($obj1);
    1078:
    1079:             } // if joined row was not null
    1080:
    1081:             $results[] = $obj1;
    1082:         }
    1083:         $stmt->closeCursor();
    1084:
    1085:         return $results;
    1086:     }
    1087:
    1088:
    1089:     /**
    1090:      * Selects a collection of Order objects pre-filled with their OrderStatus objects.
    1091:      * @param      Criteria  $criteria
    1092:      * @param      PropelPDO $con
    1093:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1094:      * @return array           Array of Order objects.
    1095:      * @throws PropelException Any exceptions caught during processing will be
    1096:      *       rethrown wrapped into a PropelException.
    1097:      */
    1098:     public static function doSelectJoinOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1099:     {
    1100:         $criteria = clone $criteria;
    1101:
    1102:         // Set the correct dbName if it has not been overridden
    1103:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1104:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1105:         }
    1106:
    1107:         OrderPeer::addSelectColumns($criteria);
    1108:         $startcol = OrderPeer::NUM_HYDRATE_COLUMNS;
    1109:         OrderStatusPeer::addSelectColumns($criteria);
    1110:
    1111:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1112:
    1113:         $stmt = BasePeer::doSelect($criteria, $con);
    1114:         $results = array();
    1115:
    1116:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1117:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1118:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1119:                 // We no longer rehydrate the object, since this can cause data loss.
    1120:                 // See http://www.propelorm.org/ticket/509
    1121:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1122:             } else {
    1123:
    1124:                 $cls = OrderPeer::getOMClass();
    1125:
    1126:                 $obj1 = new $cls();
    1127:                 $obj1->hydrate($row);
    1128:                 OrderPeer::addInstanceToPool($obj1, $key1);
    1129:             } // if $obj1 already loaded
    1130:
    1131:             $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol);
    1132:             if ($key2 !== null) {
    1133:                 $obj2 = OrderStatusPeer::getInstanceFromPool($key2);
    1134:                 if (!$obj2) {
    1135:
    1136:                     $cls = OrderStatusPeer::getOMClass();
    1137:
    1138:                     $obj2 = new $cls();
    1139:                     $obj2->hydrate($row, $startcol);
    1140:                     OrderStatusPeer::addInstanceToPool($obj2, $key2);
    1141:                 } // if obj2 already loaded
    1142:
    1143:                 // Add the $obj1 (Order) to $obj2 (OrderStatus)
    1144:                 $obj2->addOrder($obj1);
    1145:
    1146:             } // if joined row was not null
    1147:
    1148:             $results[] = $obj1;
    1149:         }
    1150:         $stmt->closeCursor();
    1151:
    1152:         return $results;
    1153:     }
    1154:
    1155:
    1156:     /**
    1157:      * Returns the number of rows matching criteria, joining all related tables
    1158:      *
    1159:      * @param      Criteria $criteria
    1160:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1161:      * @param      PropelPDO $con
    1162:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1163:      * @return int Number of matching rows.
    1164:      */
    1165:     public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1166:     {
    1167:         // we're going to modify criteria, so copy it first
    1168:         $criteria = clone $criteria;
    1169:
    1170:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1171:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1172:         // tables go into the FROM clause.
    1173:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1174:
    1175:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1176:             $criteria->setDistinct();
    1177:         }
    1178:
    1179:         if (!$criteria->hasSelectClause()) {
    1180:             OrderPeer::addSelectColumns($criteria);
    1181:         }
    1182:
    1183:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
    1184:
    1185:         // Set the correct dbName
    1186:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1187:
    1188:         if ($con === null) {
    1189:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1190:         }
    1191:
    1192:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1193:
    1194:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1195:
    1196:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1197:
    1198:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1199:
    1200:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1201:
    1202:         $stmt = BasePeer::doCount($criteria, $con);
    1203:
    1204:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1205:             $count = (int) $row[0];
    1206:         } else {
    1207:             $count = 0; // no rows returned; we infer that means 0 matches.
    1208:         }
    1209:         $stmt->closeCursor();
    1210:
    1211:         return $count;
    1212:     }
    1213:
    1214:     /**
    1215:      * Selects a collection of Order objects pre-filled with all related objects.
    1216:      *
    1217:      * @param      Criteria  $criteria
    1218:      * @param      PropelPDO $con
    1219:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1220:      * @return array           Array of Order objects.
    1221:      * @throws PropelException Any exceptions caught during processing will be
    1222:      *       rethrown wrapped into a PropelException.
    1223:      */
    1224:     public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1225:     {
    1226:         $criteria = clone $criteria;
    1227:
    1228:         // Set the correct dbName if it has not been overridden
    1229:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1230:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1231:         }
    1232:
    1233:         OrderPeer::addSelectColumns($criteria);
    1234:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    1235:
    1236:         CurrencyPeer::addSelectColumns($criteria);
    1237:         $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
    1238:
    1239:         CustomerPeer::addSelectColumns($criteria);
    1240:         $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
    1241:
    1242:         OrderAddressPeer::addSelectColumns($criteria);
    1243:         $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1244:
    1245:         OrderAddressPeer::addSelectColumns($criteria);
    1246:         $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1247:
    1248:         OrderStatusPeer::addSelectColumns($criteria);
    1249:         $startcol7 = $startcol6 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
    1250:
    1251:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1252:
    1253:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1254:
    1255:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1256:
    1257:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1258:
    1259:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1260:
    1261:         $stmt = BasePeer::doSelect($criteria, $con);
    1262:         $results = array();
    1263:
    1264:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1265:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1266:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1267:                 // We no longer rehydrate the object, since this can cause data loss.
    1268:                 // See http://www.propelorm.org/ticket/509
    1269:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1270:             } else {
    1271:                 $cls = OrderPeer::getOMClass();
    1272:
    1273:                 $obj1 = new $cls();
    1274:                 $obj1->hydrate($row);
    1275:                 OrderPeer::addInstanceToPool($obj1, $key1);
    1276:             } // if obj1 already loaded
    1277:
    1278:             // Add objects for joined Currency rows
    1279:
    1280:             $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1281:             if ($key2 !== null) {
    1282:                 $obj2 = CurrencyPeer::getInstanceFromPool($key2);
    1283:                 if (!$obj2) {
    1284:
    1285:                     $cls = CurrencyPeer::getOMClass();
    1286:
    1287:                     $obj2 = new $cls();
    1288:                     $obj2->hydrate($row, $startcol2);
    1289:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
    1290:                 } // if obj2 loaded
    1291:
    1292:                 // Add the $obj1 (Order) to the collection in $obj2 (Currency)
    1293:                 $obj2->addOrder($obj1);
    1294:             } // if joined row not null
    1295:
    1296:             // Add objects for joined Customer rows
    1297:
    1298:             $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1299:             if ($key3 !== null) {
    1300:                 $obj3 = CustomerPeer::getInstanceFromPool($key3);
    1301:                 if (!$obj3) {
    1302:
    1303:                     $cls = CustomerPeer::getOMClass();
    1304:
    1305:                     $obj3 = new $cls();
    1306:                     $obj3->hydrate($row, $startcol3);
    1307:                     CustomerPeer::addInstanceToPool($obj3, $key3);
    1308:                 } // if obj3 loaded
    1309:
    1310:                 // Add the $obj1 (Order) to the collection in $obj3 (Customer)
    1311:                 $obj3->addOrder($obj1);
    1312:             } // if joined row not null
    1313:
    1314:             // Add objects for joined OrderAddress rows
    1315:
    1316:             $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    1317:             if ($key4 !== null) {
    1318:                 $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
    1319:                 if (!$obj4) {
    1320:
    1321:                     $cls = OrderAddressPeer::getOMClass();
    1322:
    1323:                     $obj4 = new $cls();
    1324:                     $obj4->hydrate($row, $startcol4);
    1325:                     OrderAddressPeer::addInstanceToPool($obj4, $key4);
    1326:                 } // if obj4 loaded
    1327:
    1328:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
    1329:                 $obj4->addOrderRelatedByAddressInvoice($obj1);
    1330:             } // if joined row not null
    1331:
    1332:             // Add objects for joined OrderAddress rows
    1333:
    1334:             $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5);
    1335:             if ($key5 !== null) {
    1336:                 $obj5 = OrderAddressPeer::getInstanceFromPool($key5);
    1337:                 if (!$obj5) {
    1338:
    1339:                     $cls = OrderAddressPeer::getOMClass();
    1340:
    1341:                     $obj5 = new $cls();
    1342:                     $obj5->hydrate($row, $startcol5);
    1343:                     OrderAddressPeer::addInstanceToPool($obj5, $key5);
    1344:                 } // if obj5 loaded
    1345:
    1346:                 // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress)
    1347:                 $obj5->addOrderRelatedByAddressDelivery($obj1);
    1348:             } // if joined row not null
    1349:
    1350:             // Add objects for joined OrderStatus rows
    1351:
    1352:             $key6 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol6);
    1353:             if ($key6 !== null) {
    1354:                 $obj6 = OrderStatusPeer::getInstanceFromPool($key6);
    1355:                 if (!$obj6) {
    1356:
    1357:                     $cls = OrderStatusPeer::getOMClass();
    1358:
    1359:                     $obj6 = new $cls();
    1360:                     $obj6->hydrate($row, $startcol6);
    1361:                     OrderStatusPeer::addInstanceToPool($obj6, $key6);
    1362:                 } // if obj6 loaded
    1363:
    1364:                 // Add the $obj1 (Order) to the collection in $obj6 (OrderStatus)
    1365:                 $obj6->addOrder($obj1);
    1366:             } // if joined row not null
    1367:
    1368:             $results[] = $obj1;
    1369:         }
    1370:         $stmt->closeCursor();
    1371:
    1372:         return $results;
    1373:     }
    1374:
    1375:
    1376:     /**
    1377:      * Returns the number of rows matching criteria, joining the related Currency table
    1378:      *
    1379:      * @param      Criteria $criteria
    1380:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1381:      * @param      PropelPDO $con
    1382:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1383:      * @return int Number of matching rows.
    1384:      */
    1385:     public static function doCountJoinAllExceptCurrency(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1386:     {
    1387:         // we're going to modify criteria, so copy it first
    1388:         $criteria = clone $criteria;
    1389:
    1390:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1391:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1392:         // tables go into the FROM clause.
    1393:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1394:
    1395:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1396:             $criteria->setDistinct();
    1397:         }
    1398:
    1399:         if (!$criteria->hasSelectClause()) {
    1400:             OrderPeer::addSelectColumns($criteria);
    1401:         }
    1402:
    1403:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1404:
    1405:         // Set the correct dbName
    1406:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1407:
    1408:         if ($con === null) {
    1409:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1410:         }
    1411:
    1412:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1413:
    1414:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1415:
    1416:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1417:
    1418:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1419:
    1420:         $stmt = BasePeer::doCount($criteria, $con);
    1421:
    1422:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1423:             $count = (int) $row[0];
    1424:         } else {
    1425:             $count = 0; // no rows returned; we infer that means 0 matches.
    1426:         }
    1427:         $stmt->closeCursor();
    1428:
    1429:         return $count;
    1430:     }
    1431:
    1432:
    1433:     /**
    1434:      * Returns the number of rows matching criteria, joining the related Customer table
    1435:      *
    1436:      * @param      Criteria $criteria
    1437:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1438:      * @param      PropelPDO $con
    1439:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1440:      * @return int Number of matching rows.
    1441:      */
    1442:     public static function doCountJoinAllExceptCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1443:     {
    1444:         // we're going to modify criteria, so copy it first
    1445:         $criteria = clone $criteria;
    1446:
    1447:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1448:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1449:         // tables go into the FROM clause.
    1450:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1451:
    1452:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1453:             $criteria->setDistinct();
    1454:         }
    1455:
    1456:         if (!$criteria->hasSelectClause()) {
    1457:             OrderPeer::addSelectColumns($criteria);
    1458:         }
    1459:
    1460:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1461:
    1462:         // Set the correct dbName
    1463:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1464:
    1465:         if ($con === null) {
    1466:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1467:         }
    1468:
    1469:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1470:
    1471:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1472:
    1473:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1474:
    1475:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1476:
    1477:         $stmt = BasePeer::doCount($criteria, $con);
    1478:
    1479:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1480:             $count = (int) $row[0];
    1481:         } else {
    1482:             $count = 0; // no rows returned; we infer that means 0 matches.
    1483:         }
    1484:         $stmt->closeCursor();
    1485:
    1486:         return $count;
    1487:     }
    1488:
    1489:
    1490:     /**
    1491:      * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table
    1492:      *
    1493:      * @param      Criteria $criteria
    1494:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1495:      * @param      PropelPDO $con
    1496:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1497:      * @return int Number of matching rows.
    1498:      */
    1499:     public static function doCountJoinAllExceptOrderAddressRelatedByAddressInvoice(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1500:     {
    1501:         // we're going to modify criteria, so copy it first
    1502:         $criteria = clone $criteria;
    1503:
    1504:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1505:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1506:         // tables go into the FROM clause.
    1507:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1508:
    1509:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1510:             $criteria->setDistinct();
    1511:         }
    1512:
    1513:         if (!$criteria->hasSelectClause()) {
    1514:             OrderPeer::addSelectColumns($criteria);
    1515:         }
    1516:
    1517:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1518:
    1519:         // Set the correct dbName
    1520:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1521:
    1522:         if ($con === null) {
    1523:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1524:         }
    1525:
    1526:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1527:
    1528:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1529:
    1530:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1531:
    1532:         $stmt = BasePeer::doCount($criteria, $con);
    1533:
    1534:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1535:             $count = (int) $row[0];
    1536:         } else {
    1537:             $count = 0; // no rows returned; we infer that means 0 matches.
    1538:         }
    1539:         $stmt->closeCursor();
    1540:
    1541:         return $count;
    1542:     }
    1543:
    1544:
    1545:     /**
    1546:      * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table
    1547:      *
    1548:      * @param      Criteria $criteria
    1549:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1550:      * @param      PropelPDO $con
    1551:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1552:      * @return int Number of matching rows.
    1553:      */
    1554:     public static function doCountJoinAllExceptOrderAddressRelatedByAddressDelivery(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1555:     {
    1556:         // we're going to modify criteria, so copy it first
    1557:         $criteria = clone $criteria;
    1558:
    1559:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1560:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1561:         // tables go into the FROM clause.
    1562:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1563:
    1564:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1565:             $criteria->setDistinct();
    1566:         }
    1567:
    1568:         if (!$criteria->hasSelectClause()) {
    1569:             OrderPeer::addSelectColumns($criteria);
    1570:         }
    1571:
    1572:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1573:
    1574:         // Set the correct dbName
    1575:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1576:
    1577:         if ($con === null) {
    1578:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1579:         }
    1580:
    1581:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1582:
    1583:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1584:
    1585:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1586:
    1587:         $stmt = BasePeer::doCount($criteria, $con);
    1588:
    1589:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1590:             $count = (int) $row[0];
    1591:         } else {
    1592:             $count = 0; // no rows returned; we infer that means 0 matches.
    1593:         }
    1594:         $stmt->closeCursor();
    1595:
    1596:         return $count;
    1597:     }
    1598:
    1599:
    1600:     /**
    1601:      * Returns the number of rows matching criteria, joining the related OrderStatus table
    1602:      *
    1603:      * @param      Criteria $criteria
    1604:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    1605:      * @param      PropelPDO $con
    1606:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1607:      * @return int Number of matching rows.
    1608:      */
    1609:     public static function doCountJoinAllExceptOrderStatus(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1610:     {
    1611:         // we're going to modify criteria, so copy it first
    1612:         $criteria = clone $criteria;
    1613:
    1614:         // We need to set the primary table name, since in the case that there are no WHERE columns
    1615:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    1616:         // tables go into the FROM clause.
    1617:         $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    1618:
    1619:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    1620:             $criteria->setDistinct();
    1621:         }
    1622:
    1623:         if (!$criteria->hasSelectClause()) {
    1624:             OrderPeer::addSelectColumns($criteria);
    1625:         }
    1626:
    1627:         $criteria->clearOrderByColumns(); // ORDER BY should not affect count
    1628:
    1629:         // Set the correct dbName
    1630:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1631:
    1632:         if ($con === null) {
    1633:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    1634:         }
    1635:
    1636:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1637:
    1638:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1639:
    1640:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1641:
    1642:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1643:
    1644:         $stmt = BasePeer::doCount($criteria, $con);
    1645:
    1646:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1647:             $count = (int) $row[0];
    1648:         } else {
    1649:             $count = 0; // no rows returned; we infer that means 0 matches.
    1650:         }
    1651:         $stmt->closeCursor();
    1652:
    1653:         return $count;
    1654:     }
    1655:
    1656:
    1657:     /**
    1658:      * Selects a collection of Order objects pre-filled with all related objects except Currency.
    1659:      *
    1660:      * @param      Criteria  $criteria
    1661:      * @param      PropelPDO $con
    1662:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1663:      * @return array           Array of Order objects.
    1664:      * @throws PropelException Any exceptions caught during processing will be
    1665:      *       rethrown wrapped into a PropelException.
    1666:      */
    1667:     public static function doSelectJoinAllExceptCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1668:     {
    1669:         $criteria = clone $criteria;
    1670:
    1671:         // Set the correct dbName if it has not been overridden
    1672:         // $criteria->getDbName() will return the same object if not set to another value
    1673:         // so == check is okay and faster
    1674:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1675:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1676:         }
    1677:
    1678:         OrderPeer::addSelectColumns($criteria);
    1679:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    1680:
    1681:         CustomerPeer::addSelectColumns($criteria);
    1682:         $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS;
    1683:
    1684:         OrderAddressPeer::addSelectColumns($criteria);
    1685:         $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1686:
    1687:         OrderAddressPeer::addSelectColumns($criteria);
    1688:         $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1689:
    1690:         OrderStatusPeer::addSelectColumns($criteria);
    1691:         $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
    1692:
    1693:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1694:
    1695:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1696:
    1697:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1698:
    1699:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1700:
    1701:
    1702:         $stmt = BasePeer::doSelect($criteria, $con);
    1703:         $results = array();
    1704:
    1705:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1706:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1707:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1708:                 // We no longer rehydrate the object, since this can cause data loss.
    1709:                 // See http://www.propelorm.org/ticket/509
    1710:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1711:             } else {
    1712:                 $cls = OrderPeer::getOMClass();
    1713:
    1714:                 $obj1 = new $cls();
    1715:                 $obj1->hydrate($row);
    1716:                 OrderPeer::addInstanceToPool($obj1, $key1);
    1717:             } // if obj1 already loaded
    1718:
    1719:                 // Add objects for joined Customer rows
    1720:
    1721:                 $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1722:                 if ($key2 !== null) {
    1723:                     $obj2 = CustomerPeer::getInstanceFromPool($key2);
    1724:                     if (!$obj2) {
    1725:
    1726:                         $cls = CustomerPeer::getOMClass();
    1727:
    1728:                     $obj2 = new $cls();
    1729:                     $obj2->hydrate($row, $startcol2);
    1730:                     CustomerPeer::addInstanceToPool($obj2, $key2);
    1731:                 } // if $obj2 already loaded
    1732:
    1733:                 // Add the $obj1 (Order) to the collection in $obj2 (Customer)
    1734:                 $obj2->addOrder($obj1);
    1735:
    1736:             } // if joined row is not null
    1737:
    1738:                 // Add objects for joined OrderAddress rows
    1739:
    1740:                 $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1741:                 if ($key3 !== null) {
    1742:                     $obj3 = OrderAddressPeer::getInstanceFromPool($key3);
    1743:                     if (!$obj3) {
    1744:
    1745:                         $cls = OrderAddressPeer::getOMClass();
    1746:
    1747:                     $obj3 = new $cls();
    1748:                     $obj3->hydrate($row, $startcol3);
    1749:                     OrderAddressPeer::addInstanceToPool($obj3, $key3);
    1750:                 } // if $obj3 already loaded
    1751:
    1752:                 // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress)
    1753:                 $obj3->addOrderRelatedByAddressInvoice($obj1);
    1754:
    1755:             } // if joined row is not null
    1756:
    1757:                 // Add objects for joined OrderAddress rows
    1758:
    1759:                 $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    1760:                 if ($key4 !== null) {
    1761:                     $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
    1762:                     if (!$obj4) {
    1763:
    1764:                         $cls = OrderAddressPeer::getOMClass();
    1765:
    1766:                     $obj4 = new $cls();
    1767:                     $obj4->hydrate($row, $startcol4);
    1768:                     OrderAddressPeer::addInstanceToPool($obj4, $key4);
    1769:                 } // if $obj4 already loaded
    1770:
    1771:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
    1772:                 $obj4->addOrderRelatedByAddressDelivery($obj1);
    1773:
    1774:             } // if joined row is not null
    1775:
    1776:                 // Add objects for joined OrderStatus rows
    1777:
    1778:                 $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5);
    1779:                 if ($key5 !== null) {
    1780:                     $obj5 = OrderStatusPeer::getInstanceFromPool($key5);
    1781:                     if (!$obj5) {
    1782:
    1783:                         $cls = OrderStatusPeer::getOMClass();
    1784:
    1785:                     $obj5 = new $cls();
    1786:                     $obj5->hydrate($row, $startcol5);
    1787:                     OrderStatusPeer::addInstanceToPool($obj5, $key5);
    1788:                 } // if $obj5 already loaded
    1789:
    1790:                 // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus)
    1791:                 $obj5->addOrder($obj1);
    1792:
    1793:             } // if joined row is not null
    1794:
    1795:             $results[] = $obj1;
    1796:         }
    1797:         $stmt->closeCursor();
    1798:
    1799:         return $results;
    1800:     }
    1801:
    1802:
    1803:     /**
    1804:      * Selects a collection of Order objects pre-filled with all related objects except Customer.
    1805:      *
    1806:      * @param      Criteria  $criteria
    1807:      * @param      PropelPDO $con
    1808:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1809:      * @return array           Array of Order objects.
    1810:      * @throws PropelException Any exceptions caught during processing will be
    1811:      *       rethrown wrapped into a PropelException.
    1812:      */
    1813:     public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1814:     {
    1815:         $criteria = clone $criteria;
    1816:
    1817:         // Set the correct dbName if it has not been overridden
    1818:         // $criteria->getDbName() will return the same object if not set to another value
    1819:         // so == check is okay and faster
    1820:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1821:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1822:         }
    1823:
    1824:         OrderPeer::addSelectColumns($criteria);
    1825:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    1826:
    1827:         CurrencyPeer::addSelectColumns($criteria);
    1828:         $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
    1829:
    1830:         OrderAddressPeer::addSelectColumns($criteria);
    1831:         $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1832:
    1833:         OrderAddressPeer::addSelectColumns($criteria);
    1834:         $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    1835:
    1836:         OrderStatusPeer::addSelectColumns($criteria);
    1837:         $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
    1838:
    1839:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1840:
    1841:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    1842:
    1843:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    1844:
    1845:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1846:
    1847:
    1848:         $stmt = BasePeer::doSelect($criteria, $con);
    1849:         $results = array();
    1850:
    1851:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1852:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1853:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1854:                 // We no longer rehydrate the object, since this can cause data loss.
    1855:                 // See http://www.propelorm.org/ticket/509
    1856:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1857:             } else {
    1858:                 $cls = OrderPeer::getOMClass();
    1859:
    1860:                 $obj1 = new $cls();
    1861:                 $obj1->hydrate($row);
    1862:                 OrderPeer::addInstanceToPool($obj1, $key1);
    1863:             } // if obj1 already loaded
    1864:
    1865:                 // Add objects for joined Currency rows
    1866:
    1867:                 $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    1868:                 if ($key2 !== null) {
    1869:                     $obj2 = CurrencyPeer::getInstanceFromPool($key2);
    1870:                     if (!$obj2) {
    1871:
    1872:                         $cls = CurrencyPeer::getOMClass();
    1873:
    1874:                     $obj2 = new $cls();
    1875:                     $obj2->hydrate($row, $startcol2);
    1876:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
    1877:                 } // if $obj2 already loaded
    1878:
    1879:                 // Add the $obj1 (Order) to the collection in $obj2 (Currency)
    1880:                 $obj2->addOrder($obj1);
    1881:
    1882:             } // if joined row is not null
    1883:
    1884:                 // Add objects for joined OrderAddress rows
    1885:
    1886:                 $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    1887:                 if ($key3 !== null) {
    1888:                     $obj3 = OrderAddressPeer::getInstanceFromPool($key3);
    1889:                     if (!$obj3) {
    1890:
    1891:                         $cls = OrderAddressPeer::getOMClass();
    1892:
    1893:                     $obj3 = new $cls();
    1894:                     $obj3->hydrate($row, $startcol3);
    1895:                     OrderAddressPeer::addInstanceToPool($obj3, $key3);
    1896:                 } // if $obj3 already loaded
    1897:
    1898:                 // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress)
    1899:                 $obj3->addOrderRelatedByAddressInvoice($obj1);
    1900:
    1901:             } // if joined row is not null
    1902:
    1903:                 // Add objects for joined OrderAddress rows
    1904:
    1905:                 $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    1906:                 if ($key4 !== null) {
    1907:                     $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
    1908:                     if (!$obj4) {
    1909:
    1910:                         $cls = OrderAddressPeer::getOMClass();
    1911:
    1912:                     $obj4 = new $cls();
    1913:                     $obj4->hydrate($row, $startcol4);
    1914:                     OrderAddressPeer::addInstanceToPool($obj4, $key4);
    1915:                 } // if $obj4 already loaded
    1916:
    1917:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
    1918:                 $obj4->addOrderRelatedByAddressDelivery($obj1);
    1919:
    1920:             } // if joined row is not null
    1921:
    1922:                 // Add objects for joined OrderStatus rows
    1923:
    1924:                 $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5);
    1925:                 if ($key5 !== null) {
    1926:                     $obj5 = OrderStatusPeer::getInstanceFromPool($key5);
    1927:                     if (!$obj5) {
    1928:
    1929:                         $cls = OrderStatusPeer::getOMClass();
    1930:
    1931:                     $obj5 = new $cls();
    1932:                     $obj5->hydrate($row, $startcol5);
    1933:                     OrderStatusPeer::addInstanceToPool($obj5, $key5);
    1934:                 } // if $obj5 already loaded
    1935:
    1936:                 // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus)
    1937:                 $obj5->addOrder($obj1);
    1938:
    1939:             } // if joined row is not null
    1940:
    1941:             $results[] = $obj1;
    1942:         }
    1943:         $stmt->closeCursor();
    1944:
    1945:         return $results;
    1946:     }
    1947:
    1948:
    1949:     /**
    1950:      * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressInvoice.
    1951:      *
    1952:      * @param      Criteria  $criteria
    1953:      * @param      PropelPDO $con
    1954:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    1955:      * @return array           Array of Order objects.
    1956:      * @throws PropelException Any exceptions caught during processing will be
    1957:      *       rethrown wrapped into a PropelException.
    1958:      */
    1959:     public static function doSelectJoinAllExceptOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1960:     {
    1961:         $criteria = clone $criteria;
    1962:
    1963:         // Set the correct dbName if it has not been overridden
    1964:         // $criteria->getDbName() will return the same object if not set to another value
    1965:         // so == check is okay and faster
    1966:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    1967:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    1968:         }
    1969:
    1970:         OrderPeer::addSelectColumns($criteria);
    1971:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    1972:
    1973:         CurrencyPeer::addSelectColumns($criteria);
    1974:         $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
    1975:
    1976:         CustomerPeer::addSelectColumns($criteria);
    1977:         $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
    1978:
    1979:         OrderStatusPeer::addSelectColumns($criteria);
    1980:         $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
    1981:
    1982:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    1983:
    1984:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    1985:
    1986:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    1987:
    1988:
    1989:         $stmt = BasePeer::doSelect($criteria, $con);
    1990:         $results = array();
    1991:
    1992:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    1993:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    1994:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    1995:                 // We no longer rehydrate the object, since this can cause data loss.
    1996:                 // See http://www.propelorm.org/ticket/509
    1997:                 // $obj1->hydrate($row, 0, true); // rehydrate
    1998:             } else {
    1999:                 $cls = OrderPeer::getOMClass();
    2000:
    2001:                 $obj1 = new $cls();
    2002:                 $obj1->hydrate($row);
    2003:                 OrderPeer::addInstanceToPool($obj1, $key1);
    2004:             } // if obj1 already loaded
    2005:
    2006:                 // Add objects for joined Currency rows
    2007:
    2008:                 $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    2009:                 if ($key2 !== null) {
    2010:                     $obj2 = CurrencyPeer::getInstanceFromPool($key2);
    2011:                     if (!$obj2) {
    2012:
    2013:                         $cls = CurrencyPeer::getOMClass();
    2014:
    2015:                     $obj2 = new $cls();
    2016:                     $obj2->hydrate($row, $startcol2);
    2017:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
    2018:                 } // if $obj2 already loaded
    2019:
    2020:                 // Add the $obj1 (Order) to the collection in $obj2 (Currency)
    2021:                 $obj2->addOrder($obj1);
    2022:
    2023:             } // if joined row is not null
    2024:
    2025:                 // Add objects for joined Customer rows
    2026:
    2027:                 $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    2028:                 if ($key3 !== null) {
    2029:                     $obj3 = CustomerPeer::getInstanceFromPool($key3);
    2030:                     if (!$obj3) {
    2031:
    2032:                         $cls = CustomerPeer::getOMClass();
    2033:
    2034:                     $obj3 = new $cls();
    2035:                     $obj3->hydrate($row, $startcol3);
    2036:                     CustomerPeer::addInstanceToPool($obj3, $key3);
    2037:                 } // if $obj3 already loaded
    2038:
    2039:                 // Add the $obj1 (Order) to the collection in $obj3 (Customer)
    2040:                 $obj3->addOrder($obj1);
    2041:
    2042:             } // if joined row is not null
    2043:
    2044:                 // Add objects for joined OrderStatus rows
    2045:
    2046:                 $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    2047:                 if ($key4 !== null) {
    2048:                     $obj4 = OrderStatusPeer::getInstanceFromPool($key4);
    2049:                     if (!$obj4) {
    2050:
    2051:                         $cls = OrderStatusPeer::getOMClass();
    2052:
    2053:                     $obj4 = new $cls();
    2054:                     $obj4->hydrate($row, $startcol4);
    2055:                     OrderStatusPeer::addInstanceToPool($obj4, $key4);
    2056:                 } // if $obj4 already loaded
    2057:
    2058:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus)
    2059:                 $obj4->addOrder($obj1);
    2060:
    2061:             } // if joined row is not null
    2062:
    2063:             $results[] = $obj1;
    2064:         }
    2065:         $stmt->closeCursor();
    2066:
    2067:         return $results;
    2068:     }
    2069:
    2070:
    2071:     /**
    2072:      * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressDelivery.
    2073:      *
    2074:      * @param      Criteria  $criteria
    2075:      * @param      PropelPDO $con
    2076:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    2077:      * @return array           Array of Order objects.
    2078:      * @throws PropelException Any exceptions caught during processing will be
    2079:      *       rethrown wrapped into a PropelException.
    2080:      */
    2081:     public static function doSelectJoinAllExceptOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    2082:     {
    2083:         $criteria = clone $criteria;
    2084:
    2085:         // Set the correct dbName if it has not been overridden
    2086:         // $criteria->getDbName() will return the same object if not set to another value
    2087:         // so == check is okay and faster
    2088:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    2089:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    2090:         }
    2091:
    2092:         OrderPeer::addSelectColumns($criteria);
    2093:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    2094:
    2095:         CurrencyPeer::addSelectColumns($criteria);
    2096:         $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
    2097:
    2098:         CustomerPeer::addSelectColumns($criteria);
    2099:         $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
    2100:
    2101:         OrderStatusPeer::addSelectColumns($criteria);
    2102:         $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS;
    2103:
    2104:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    2105:
    2106:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    2107:
    2108:         $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior);
    2109:
    2110:
    2111:         $stmt = BasePeer::doSelect($criteria, $con);
    2112:         $results = array();
    2113:
    2114:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    2115:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    2116:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    2117:                 // We no longer rehydrate the object, since this can cause data loss.
    2118:                 // See http://www.propelorm.org/ticket/509
    2119:                 // $obj1->hydrate($row, 0, true); // rehydrate
    2120:             } else {
    2121:                 $cls = OrderPeer::getOMClass();
    2122:
    2123:                 $obj1 = new $cls();
    2124:                 $obj1->hydrate($row);
    2125:                 OrderPeer::addInstanceToPool($obj1, $key1);
    2126:             } // if obj1 already loaded
    2127:
    2128:                 // Add objects for joined Currency rows
    2129:
    2130:                 $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    2131:                 if ($key2 !== null) {
    2132:                     $obj2 = CurrencyPeer::getInstanceFromPool($key2);
    2133:                     if (!$obj2) {
    2134:
    2135:                         $cls = CurrencyPeer::getOMClass();
    2136:
    2137:                     $obj2 = new $cls();
    2138:                     $obj2->hydrate($row, $startcol2);
    2139:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
    2140:                 } // if $obj2 already loaded
    2141:
    2142:                 // Add the $obj1 (Order) to the collection in $obj2 (Currency)
    2143:                 $obj2->addOrder($obj1);
    2144:
    2145:             } // if joined row is not null
    2146:
    2147:                 // Add objects for joined Customer rows
    2148:
    2149:                 $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    2150:                 if ($key3 !== null) {
    2151:                     $obj3 = CustomerPeer::getInstanceFromPool($key3);
    2152:                     if (!$obj3) {
    2153:
    2154:                         $cls = CustomerPeer::getOMClass();
    2155:
    2156:                     $obj3 = new $cls();
    2157:                     $obj3->hydrate($row, $startcol3);
    2158:                     CustomerPeer::addInstanceToPool($obj3, $key3);
    2159:                 } // if $obj3 already loaded
    2160:
    2161:                 // Add the $obj1 (Order) to the collection in $obj3 (Customer)
    2162:                 $obj3->addOrder($obj1);
    2163:
    2164:             } // if joined row is not null
    2165:
    2166:                 // Add objects for joined OrderStatus rows
    2167:
    2168:                 $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    2169:                 if ($key4 !== null) {
    2170:                     $obj4 = OrderStatusPeer::getInstanceFromPool($key4);
    2171:                     if (!$obj4) {
    2172:
    2173:                         $cls = OrderStatusPeer::getOMClass();
    2174:
    2175:                     $obj4 = new $cls();
    2176:                     $obj4->hydrate($row, $startcol4);
    2177:                     OrderStatusPeer::addInstanceToPool($obj4, $key4);
    2178:                 } // if $obj4 already loaded
    2179:
    2180:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus)
    2181:                 $obj4->addOrder($obj1);
    2182:
    2183:             } // if joined row is not null
    2184:
    2185:             $results[] = $obj1;
    2186:         }
    2187:         $stmt->closeCursor();
    2188:
    2189:         return $results;
    2190:     }
    2191:
    2192:
    2193:     /**
    2194:      * Selects a collection of Order objects pre-filled with all related objects except OrderStatus.
    2195:      *
    2196:      * @param      Criteria  $criteria
    2197:      * @param      PropelPDO $con
    2198:      * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
    2199:      * @return array           Array of Order objects.
    2200:      * @throws PropelException Any exceptions caught during processing will be
    2201:      *       rethrown wrapped into a PropelException.
    2202:      */
    2203:     public static function doSelectJoinAllExceptOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    2204:     {
    2205:         $criteria = clone $criteria;
    2206:
    2207:         // Set the correct dbName if it has not been overridden
    2208:         // $criteria->getDbName() will return the same object if not set to another value
    2209:         // so == check is okay and faster
    2210:         if ($criteria->getDbName() == Propel::getDefaultDB()) {
    2211:             $criteria->setDbName(OrderPeer::DATABASE_NAME);
    2212:         }
    2213:
    2214:         OrderPeer::addSelectColumns($criteria);
    2215:         $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS;
    2216:
    2217:         CurrencyPeer::addSelectColumns($criteria);
    2218:         $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS;
    2219:
    2220:         CustomerPeer::addSelectColumns($criteria);
    2221:         $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS;
    2222:
    2223:         OrderAddressPeer::addSelectColumns($criteria);
    2224:         $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    2225:
    2226:         OrderAddressPeer::addSelectColumns($criteria);
    2227:         $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS;
    2228:
    2229:         $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior);
    2230:
    2231:         $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior);
    2232:
    2233:         $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior);
    2234:
    2235:         $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior);
    2236:
    2237:
    2238:         $stmt = BasePeer::doSelect($criteria, $con);
    2239:         $results = array();
    2240:
    2241:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    2242:             $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0);
    2243:             if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) {
    2244:                 // We no longer rehydrate the object, since this can cause data loss.
    2245:                 // See http://www.propelorm.org/ticket/509
    2246:                 // $obj1->hydrate($row, 0, true); // rehydrate
    2247:             } else {
    2248:                 $cls = OrderPeer::getOMClass();
    2249:
    2250:                 $obj1 = new $cls();
    2251:                 $obj1->hydrate($row);
    2252:                 OrderPeer::addInstanceToPool($obj1, $key1);
    2253:             } // if obj1 already loaded
    2254:
    2255:                 // Add objects for joined Currency rows
    2256:
    2257:                 $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
    2258:                 if ($key2 !== null) {
    2259:                     $obj2 = CurrencyPeer::getInstanceFromPool($key2);
    2260:                     if (!$obj2) {
    2261:
    2262:                         $cls = CurrencyPeer::getOMClass();
    2263:
    2264:                     $obj2 = new $cls();
    2265:                     $obj2->hydrate($row, $startcol2);
    2266:                     CurrencyPeer::addInstanceToPool($obj2, $key2);
    2267:                 } // if $obj2 already loaded
    2268:
    2269:                 // Add the $obj1 (Order) to the collection in $obj2 (Currency)
    2270:                 $obj2->addOrder($obj1);
    2271:
    2272:             } // if joined row is not null
    2273:
    2274:                 // Add objects for joined Customer rows
    2275:
    2276:                 $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3);
    2277:                 if ($key3 !== null) {
    2278:                     $obj3 = CustomerPeer::getInstanceFromPool($key3);
    2279:                     if (!$obj3) {
    2280:
    2281:                         $cls = CustomerPeer::getOMClass();
    2282:
    2283:                     $obj3 = new $cls();
    2284:                     $obj3->hydrate($row, $startcol3);
    2285:                     CustomerPeer::addInstanceToPool($obj3, $key3);
    2286:                 } // if $obj3 already loaded
    2287:
    2288:                 // Add the $obj1 (Order) to the collection in $obj3 (Customer)
    2289:                 $obj3->addOrder($obj1);
    2290:
    2291:             } // if joined row is not null
    2292:
    2293:                 // Add objects for joined OrderAddress rows
    2294:
    2295:                 $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4);
    2296:                 if ($key4 !== null) {
    2297:                     $obj4 = OrderAddressPeer::getInstanceFromPool($key4);
    2298:                     if (!$obj4) {
    2299:
    2300:                         $cls = OrderAddressPeer::getOMClass();
    2301:
    2302:                     $obj4 = new $cls();
    2303:                     $obj4->hydrate($row, $startcol4);
    2304:                     OrderAddressPeer::addInstanceToPool($obj4, $key4);
    2305:                 } // if $obj4 already loaded
    2306:
    2307:                 // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress)
    2308:                 $obj4->addOrderRelatedByAddressInvoice($obj1);
    2309:
    2310:             } // if joined row is not null
    2311:
    2312:                 // Add objects for joined OrderAddress rows
    2313:
    2314:                 $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5);
    2315:                 if ($key5 !== null) {
    2316:                     $obj5 = OrderAddressPeer::getInstanceFromPool($key5);
    2317:                     if (!$obj5) {
    2318:
    2319:                         $cls = OrderAddressPeer::getOMClass();
    2320:
    2321:                     $obj5 = new $cls();
    2322:                     $obj5->hydrate($row, $startcol5);
    2323:                     OrderAddressPeer::addInstanceToPool($obj5, $key5);
    2324:                 } // if $obj5 already loaded
    2325:
    2326:                 // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress)
    2327:                 $obj5->addOrderRelatedByAddressDelivery($obj1);
    2328:
    2329:             } // if joined row is not null
    2330:
    2331:             $results[] = $obj1;
    2332:         }
    2333:         $stmt->closeCursor();
    2334:
    2335:         return $results;
    2336:     }
    2337:
    2338:     /**
    2339:      * Returns the TableMap related to this peer.
    2340:      * This method is not needed for general use but a specific application could have a need.
    2341:      * @return TableMap
    2342:      * @throws PropelException Any exceptions caught during processing will be
    2343:      *       rethrown wrapped into a PropelException.
    2344:      */
    2345:     public static function getTableMap()
    2346:     {
    2347:         return Propel::getDatabaseMap(OrderPeer::DATABASE_NAME)->getTable(OrderPeer::TABLE_NAME);
    2348:     }
    2349:
    2350:     /**
    2351:      * Add a TableMap instance to the database for this peer class.
    2352:      */
    2353:     public static function buildTableMap()
    2354:     {
    2355:       $dbMap = Propel::getDatabaseMap(BaseOrderPeer::DATABASE_NAME);
    2356:       if (!$dbMap->hasTable(BaseOrderPeer::TABLE_NAME)) {
    2357:         $dbMap->addTableObject(new OrderTableMap());
    2358:       }
    2359:     }
    2360:
    2361:     /**
    2362:      * The class that the Peer will make instances of.
    2363:      *
    2364:      *
    2365:      * @return string ClassName
    2366:      */
    2367:     public static function getOMClass($row = 0, $colnum = 0)
    2368:     {
    2369:         return OrderPeer::OM_CLASS;
    2370:     }
    2371:
    2372:     /**
    2373:      * Performs an INSERT on the database, given a Order or Criteria object.
    2374:      *
    2375:      * @param      mixed $values Criteria or Order object containing data that is used to create the INSERT statement.
    2376:      * @param      PropelPDO $con the PropelPDO connection to use
    2377:      * @return mixed           The new primary key.
    2378:      * @throws PropelException Any exceptions caught during processing will be
    2379:      *       rethrown wrapped into a PropelException.
    2380:      */
    2381:     public static function doInsert($values, PropelPDO $con = null)
    2382:     {
    2383:         if ($con === null) {
    2384:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    2385:         }
    2386:
    2387:         if ($values instanceof Criteria) {
    2388:             $criteria = clone $values; // rename for clarity
    2389:         } else {
    2390:             $criteria = $values->buildCriteria(); // build Criteria from Order object
    2391:         }
    2392:
    2393:         if ($criteria->containsKey(OrderPeer::ID) && $criteria->keyContainsValue(OrderPeer::ID) ) {
    2394:             throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderPeer::ID.')');
    2395:         }
    2396:
    2397:
    2398:         // Set the correct dbName
    2399:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    2400:
    2401:         try {
    2402:             // use transaction because $criteria could contain info
    2403:             // for more than one table (I guess, conceivably)
    2404:             $con->beginTransaction();
    2405:             $pk = BasePeer::doInsert($criteria, $con);
    2406:             $con->commit();
    2407:         } catch (PropelException $e) {
    2408:             $con->rollBack();
    2409:             throw $e;
    2410:         }
    2411:
    2412:         return $pk;
    2413:     }
    2414:
    2415:     /**
    2416:      * Performs an UPDATE on the database, given a Order or Criteria object.
    2417:      *
    2418:      * @param      mixed $values Criteria or Order object containing data that is used to create the UPDATE statement.
    2419:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
    2420:      * @return int             The number of affected rows (if supported by underlying database driver).
    2421:      * @throws PropelException Any exceptions caught during processing will be
    2422:      *       rethrown wrapped into a PropelException.
    2423:      */
    2424:     public static function doUpdate($values, PropelPDO $con = null)
    2425:     {
    2426:         if ($con === null) {
    2427:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    2428:         }
    2429:
    2430:         $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME);
    2431:
    2432:         if ($values instanceof Criteria) {
    2433:             $criteria = clone $values; // rename for clarity
    2434:
    2435:             $comparison = $criteria->getComparison(OrderPeer::ID);
    2436:             $value = $criteria->remove(OrderPeer::ID);
    2437:             if ($value) {
    2438:                 $selectCriteria->add(OrderPeer::ID, $value, $comparison);
    2439:             } else {
    2440:                 $selectCriteria->setPrimaryTableName(OrderPeer::TABLE_NAME);
    2441:             }
    2442:
    2443:         } else { // $values is Order object
    2444:             $criteria = $values->buildCriteria(); // gets full criteria
    2445:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
    2446:         }
    2447:
    2448:         // set the correct dbName
    2449:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    2450:
    2451:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    2452:     }
    2453:
    2454:     /**
    2455:      * Deletes all rows from the order table.
    2456:      *
    2457:      * @param      PropelPDO $con the connection to use
    2458:      * @return int             The number of affected rows (if supported by underlying database driver).
    2459:      * @throws PropelException
    2460:      */
    2461:     public static function doDeleteAll(PropelPDO $con = null)
    2462:     {
    2463:         if ($con === null) {
    2464:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    2465:         }
    2466:         $affectedRows = 0; // initialize var to track total num of affected rows
    2467:         try {
    2468:             // use transaction because $criteria could contain info
    2469:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    2470:             $con->beginTransaction();
    2471:             $affectedRows += BasePeer::doDeleteAll(OrderPeer::TABLE_NAME, $con, OrderPeer::DATABASE_NAME);
    2472:             // Because this db requires some delete cascade/set null emulation, we have to
    2473:             // clear the cached instance *after* the emulation has happened (since
    2474:             // instances get re-added by the select statement contained therein).
    2475:             OrderPeer::clearInstancePool();
    2476:             OrderPeer::clearRelatedInstancePool();
    2477:             $con->commit();
    2478:
    2479:             return $affectedRows;
    2480:         } catch (PropelException $e) {
    2481:             $con->rollBack();
    2482:             throw $e;
    2483:         }
    2484:     }
    2485:
    2486:     /**
    2487:      * Performs a DELETE on the database, given a Order or Criteria object OR a primary key value.
    2488:      *
    2489:      * @param      mixed $values Criteria or Order object or primary key or array of primary keys
    2490:      *              which is used to create the DELETE statement
    2491:      * @param      PropelPDO $con the connection to use
    2492:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
    2493:      *              if supported by native driver or if emulated using Propel.
    2494:      * @throws PropelException Any exceptions caught during processing will be
    2495:      *       rethrown wrapped into a PropelException.
    2496:      */
    2497:      public static function doDelete($values, PropelPDO $con = null)
    2498:      {
    2499:         if ($con === null) {
    2500:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    2501:         }
    2502:
    2503:         if ($values instanceof Criteria) {
    2504:             // invalidate the cache for all objects of this type, since we have no
    2505:             // way of knowing (without running a query) what objects should be invalidated
    2506:             // from the cache based on this Criteria.
    2507:             OrderPeer::clearInstancePool();
    2508:             // rename for clarity
    2509:             $criteria = clone $values;
    2510:         } elseif ($values instanceof Order) { // it's a model object
    2511:             // invalidate the cache for this single object
    2512:             OrderPeer::removeInstanceFromPool($values);
    2513:             // create criteria based on pk values
    2514:             $criteria = $values->buildPkeyCriteria();
    2515:         } else { // it's a primary key, or an array of pks
    2516:             $criteria = new Criteria(OrderPeer::DATABASE_NAME);
    2517:             $criteria->add(OrderPeer::ID, (array) $values, Criteria::IN);
    2518:             // invalidate the cache for this object(s)
    2519:             foreach ((array) $values as $singleval) {
    2520:                 OrderPeer::removeInstanceFromPool($singleval);
    2521:             }
    2522:         }
    2523:
    2524:         // Set the correct dbName
    2525:         $criteria->setDbName(OrderPeer::DATABASE_NAME);
    2526:
    2527:         $affectedRows = 0; // initialize var to track total num of affected rows
    2528:
    2529:         try {
    2530:             // use transaction because $criteria could contain info
    2531:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    2532:             $con->beginTransaction();
    2533:
    2534:             $affectedRows += BasePeer::doDelete($criteria, $con);
    2535:             OrderPeer::clearRelatedInstancePool();
    2536:             $con->commit();
    2537:
    2538:             return $affectedRows;
    2539:         } catch (PropelException $e) {
    2540:             $con->rollBack();
    2541:             throw $e;
    2542:         }
    2543:     }
    2544:
    2545:     /**
    2546:      * Validates all modified columns of given Order object.
    2547:      * If parameter $columns is either a single column name or an array of column names
    2548:      * than only those columns are validated.
    2549:      *
    2550:      * NOTICE: This does not apply to primary or foreign keys for now.
    2551:      *
    2552:      * @param      Order $obj The object to validate.
    2553:      * @param      mixed $cols Column name or array of column names.
    2554:      *
    2555:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
    2556:      */
    2557:     public static function doValidate($obj, $cols = null)
    2558:     {
    2559:         $columns = array();
    2560:
    2561:         if ($cols) {
    2562:             $dbMap = Propel::getDatabaseMap(OrderPeer::DATABASE_NAME);
    2563:             $tableMap = $dbMap->getTable(OrderPeer::TABLE_NAME);
    2564:
    2565:             if (! is_array($cols)) {
    2566:                 $cols = array($cols);
    2567:             }
    2568:
    2569:             foreach ($cols as $colName) {
    2570:                 if ($tableMap->hasColumn($colName)) {
    2571:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
    2572:                     $columns[$colName] = $obj->$get();
    2573:                 }
    2574:             }
    2575:         } else {
    2576:
    2577:         }
    2578:
    2579:         return BasePeer::doValidate(OrderPeer::DATABASE_NAME, OrderPeer::TABLE_NAME, $columns);
    2580:     }
    2581:
    2582:     /**
    2583:      * Retrieve a single object by pkey.
    2584:      *
    2585:      * @param      int $pk the primary key.
    2586:      * @param      PropelPDO $con the connection to use
    2587:      * @return Order
    2588:      */
    2589:     public static function retrieveByPK($pk, PropelPDO $con = null)
    2590:     {
    2591:
    2592:         if (null !== ($obj = OrderPeer::getInstanceFromPool((string) $pk))) {
    2593:             return $obj;
    2594:         }
    2595:
    2596:         if ($con === null) {
    2597:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    2598:         }
    2599:
    2600:         $criteria = new Criteria(OrderPeer::DATABASE_NAME);
    2601:         $criteria->add(OrderPeer::ID, $pk);
    2602:
    2603:         $v = OrderPeer::doSelect($criteria, $con);
    2604:
    2605:         return !empty($v) > 0 ? $v[0] : null;
    2606:     }
    2607:
    2608:     /**
    2609:      * Retrieve multiple objects by pkey.
    2610:      *
    2611:      * @param      array $pks List of primary keys
    2612:      * @param      PropelPDO $con the connection to use
    2613:      * @return Order[]
    2614:      * @throws PropelException Any exceptions caught during processing will be
    2615:      *       rethrown wrapped into a PropelException.
    2616:      */
    2617:     public static function retrieveByPKs($pks, PropelPDO $con = null)
    2618:     {
    2619:         if ($con === null) {
    2620:             $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    2621:         }
    2622:
    2623:         $objs = null;
    2624:         if (empty($pks)) {
    2625:             $objs = array();
    2626:         } else {
    2627:             $criteria = new Criteria(OrderPeer::DATABASE_NAME);
    2628:             $criteria->add(OrderPeer::ID, $pks, Criteria::IN);
    2629:             $objs = OrderPeer::doSelect($criteria, $con);
    2630:         }
    2631:
    2632:         return $objs;
    2633:     }
    2634:
    2635: } // BaseOrderPeer
    2636:
    2637: // This is the static code needed to register the TableMap for this table with the main Propel class.
    2638: //
    2639: BaseOrderPeer::buildTableMap();
    2640:
    2641: