Overview

Namespaces

  • PHP
  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvDesc
  • BaseAttributeAvDescPeer
  • BaseAttributeAvDescQuery
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeDesc
  • BaseAttributeDescPeer
  • BaseAttributeDescQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryDesc
  • BaseCategoryDescPeer
  • BaseCategoryDescQuery
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigDesc
  • BaseConfigDescPeer
  • BaseConfigDescQuery
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentDesc
  • BaseContentDescPeer
  • BaseContentDescQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryDesc
  • BaseCountryDescPeer
  • BaseCountryDescQuery
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleDesc
  • BaseCustomerTitleDescPeer
  • BaseCustomerTitleDescQuery
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentDesc
  • BaseDocumentDescPeer
  • BaseDocumentDescQuery
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvDesc
  • BaseFeatureAvDescPeer
  • BaseFeatureAvDescQuery
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureDesc
  • BaseFeatureDescPeer
  • BaseFeatureDescQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderDesc
  • BaseFolderDescPeer
  • BaseFolderDescQuery
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupDesc
  • BaseGroupDescPeer
  • BaseGroupDescQuery
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageDesc
  • BaseImageDescPeer
  • BaseImageDescQuery
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageDesc
  • BaseMessageDescPeer
  • BaseMessageDescQuery
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModuleDesc
  • BaseModuleDescPeer
  • BaseModuleDescQuery
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusDesc
  • BaseOrderStatusDescPeer
  • BaseOrderStatusDescQuery
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductDesc
  • BaseProductDescPeer
  • BaseProductDescQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceDesc
  • BaseResourceDescPeer
  • BaseResourceDescQuery
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxDesc
  • BaseTaxDescPeer
  • BaseTaxDescQuery
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleDesc
  • BaseTaxRuleDescPeer
  • BaseTaxRuleDescQuery
  • BaseTaxRuleI18n
  • BaseTaxRuleI18nPeer
  • BaseTaxRuleI18nQuery
  • BaseTaxRulePeer
  • BaseTaxRuleQuery
  • Overview
  • Namespace
  • Class
  • Tree
  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\Coupon;
 13: use Thelia\Model\CouponPeer;
 14: use Thelia\Model\CouponRulePeer;
 15: use Thelia\Model\map\CouponTableMap;
 16: 
 17: /**
 18:  * Base static class for performing query and update operations on the 'coupon' table.
 19:  *
 20:  *
 21:  *
 22:  * @package propel.generator.Thelia.Model.om
 23:  */
 24: abstract class BaseCouponPeer
 25: {
 26: 
 27:     /** the default database name for this class */
 28:     const DATABASE_NAME = 'thelia';
 29: 
 30:     /** the table name for this class */
 31:     const TABLE_NAME = 'coupon';
 32: 
 33:     /** the related Propel class for this table */
 34:     const OM_CLASS = 'Thelia\\Model\\Coupon';
 35: 
 36:     /** the related TableMap class for this table */
 37:     const TM_CLASS = 'CouponTableMap';
 38: 
 39:     /** The total number of columns. */
 40:     const NUM_COLUMNS = 10;
 41: 
 42:     /** The number of lazy-loaded columns. */
 43:     const NUM_LAZY_LOAD_COLUMNS = 0;
 44: 
 45:     /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
 46:     const NUM_HYDRATE_COLUMNS = 10;
 47: 
 48:     /** the column name for the ID field */
 49:     const ID = 'coupon.ID';
 50: 
 51:     /** the column name for the CODE field */
 52:     const CODE = 'coupon.CODE';
 53: 
 54:     /** the column name for the ACTION field */
 55:     const ACTION = 'coupon.ACTION';
 56: 
 57:     /** the column name for the VALUE field */
 58:     const VALUE = 'coupon.VALUE';
 59: 
 60:     /** the column name for the USED field */
 61:     const USED = 'coupon.USED';
 62: 
 63:     /** the column name for the AVAILABLE_SINCE field */
 64:     const AVAILABLE_SINCE = 'coupon.AVAILABLE_SINCE';
 65: 
 66:     /** the column name for the DATE_LIMIT field */
 67:     const DATE_LIMIT = 'coupon.DATE_LIMIT';
 68: 
 69:     /** the column name for the ACTIVATE field */
 70:     const ACTIVATE = 'coupon.ACTIVATE';
 71: 
 72:     /** the column name for the CREATED_AT field */
 73:     const CREATED_AT = 'coupon.CREATED_AT';
 74: 
 75:     /** the column name for the UPDATED_AT field */
 76:     const UPDATED_AT = 'coupon.UPDATED_AT';
 77: 
 78:     /** The default string format for model objects of the related table **/
 79:     const DEFAULT_STRING_FORMAT = 'YAML';
 80: 
 81:     /**
 82:      * An identiy map to hold any loaded instances of Coupon objects.
 83:      * This must be public so that other peer classes can access this when hydrating from JOIN
 84:      * queries.
 85:      * @var        array Coupon[]
 86:      */
 87:     public static $instances = array();
 88: 
 89: 
 90:     /**
 91:      * holds an array of fieldnames
 92:      *
 93:      * first dimension keys are the type constants
 94:      * e.g. CouponPeer::$fieldNames[CouponPeer::TYPE_PHPNAME][0] = 'Id'
 95:      */
 96:     protected static $fieldNames = array (
 97:         BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ),
 98:         BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ),
 99:         BasePeer::TYPE_COLNAME => array (CouponPeer::ID, CouponPeer::CODE, CouponPeer::ACTION, CouponPeer::VALUE, CouponPeer::USED, CouponPeer::AVAILABLE_SINCE, CouponPeer::DATE_LIMIT, CouponPeer::ACTIVATE, CouponPeer::CREATED_AT, CouponPeer::UPDATED_AT, ),
100:         BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ),
101:         BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ),
102:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
103:     );
104: 
105:     /**
106:      * holds an array of keys for quick access to the fieldnames array
107:      *
108:      * first dimension keys are the type constants
109:      * e.g. CouponPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
110:      */
111:     protected static $fieldKeys = array (
112:         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ),
113:         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ),
114:         BasePeer::TYPE_COLNAME => array (CouponPeer::ID => 0, CouponPeer::CODE => 1, CouponPeer::ACTION => 2, CouponPeer::VALUE => 3, CouponPeer::USED => 4, CouponPeer::AVAILABLE_SINCE => 5, CouponPeer::DATE_LIMIT => 6, CouponPeer::ACTIVATE => 7, CouponPeer::CREATED_AT => 8, CouponPeer::UPDATED_AT => 9, ),
115:         BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ),
116:         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ),
117:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
118:     );
119: 
120:     /**
121:      * Translates a fieldname to another type
122:      *
123:      * @param      string $name field name
124:      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
125:      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
126:      * @param      string $toType   One of the class type constants
127:      * @return string          translated name of the field.
128:      * @throws PropelException - if the specified name could not be found in the fieldname mappings.
129:      */
130:     public static function translateFieldName($name, $fromType, $toType)
131:     {
132:         $toNames = CouponPeer::getFieldNames($toType);
133:         $key = isset(CouponPeer::$fieldKeys[$fromType][$name]) ? CouponPeer::$fieldKeys[$fromType][$name] : null;
134:         if ($key === null) {
135:             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponPeer::$fieldKeys[$fromType], true));
136:         }
137: 
138:         return $toNames[$key];
139:     }
140: 
141:     /**
142:      * Returns an array of field names.
143:      *
144:      * @param      string $type The type of fieldnames to return:
145:      *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
146:      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
147:      * @return array           A list of field names
148:      * @throws PropelException - if the type is not valid.
149:      */
150:     public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
151:     {
152:         if (!array_key_exists($type, CouponPeer::$fieldNames)) {
153:             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.');
154:         }
155: 
156:         return CouponPeer::$fieldNames[$type];
157:     }
158: 
159:     /**
160:      * Convenience method which changes table.column to alias.column.
161:      *
162:      * Using this method you can maintain SQL abstraction while using column aliases.
163:      * <code>
164:      *      $c->addAlias("alias1", TablePeer::TABLE_NAME);
165:      *      $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
166:      * </code>
167:      * @param      string $alias The alias for the current table.
168:      * @param      string $column The column name for current table. (i.e. CouponPeer::COLUMN_NAME).
169:      * @return string
170:      */
171:     public static function alias($alias, $column)
172:     {
173:         return str_replace(CouponPeer::TABLE_NAME.'.', $alias.'.', $column);
174:     }
175: 
176:     /**
177:      * Add all the columns needed to create a new object.
178:      *
179:      * Note: any columns that were marked with lazyLoad="true" in the
180:      * XML schema will not be added to the select list and only loaded
181:      * on demand.
182:      *
183:      * @param      Criteria $criteria object containing the columns to add.
184:      * @param      string   $alias    optional table alias
185:      * @throws PropelException Any exceptions caught during processing will be
186:      *       rethrown wrapped into a PropelException.
187:      */
188:     public static function addSelectColumns(Criteria $criteria, $alias = null)
189:     {
190:         if (null === $alias) {
191:             $criteria->addSelectColumn(CouponPeer::ID);
192:             $criteria->addSelectColumn(CouponPeer::CODE);
193:             $criteria->addSelectColumn(CouponPeer::ACTION);
194:             $criteria->addSelectColumn(CouponPeer::VALUE);
195:             $criteria->addSelectColumn(CouponPeer::USED);
196:             $criteria->addSelectColumn(CouponPeer::AVAILABLE_SINCE);
197:             $criteria->addSelectColumn(CouponPeer::DATE_LIMIT);
198:             $criteria->addSelectColumn(CouponPeer::ACTIVATE);
199:             $criteria->addSelectColumn(CouponPeer::CREATED_AT);
200:             $criteria->addSelectColumn(CouponPeer::UPDATED_AT);
201:         } else {
202:             $criteria->addSelectColumn($alias . '.ID');
203:             $criteria->addSelectColumn($alias . '.CODE');
204:             $criteria->addSelectColumn($alias . '.ACTION');
205:             $criteria->addSelectColumn($alias . '.VALUE');
206:             $criteria->addSelectColumn($alias . '.USED');
207:             $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE');
208:             $criteria->addSelectColumn($alias . '.DATE_LIMIT');
209:             $criteria->addSelectColumn($alias . '.ACTIVATE');
210:             $criteria->addSelectColumn($alias . '.CREATED_AT');
211:             $criteria->addSelectColumn($alias . '.UPDATED_AT');
212:         }
213:     }
214: 
215:     /**
216:      * Returns the number of rows matching criteria.
217:      *
218:      * @param      Criteria $criteria
219:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
220:      * @param      PropelPDO $con
221:      * @return int Number of matching rows.
222:      */
223:     public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
224:     {
225:         // we may modify criteria, so copy it first
226:         $criteria = clone $criteria;
227: 
228:         // We need to set the primary table name, since in the case that there are no WHERE columns
229:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
230:         // tables go into the FROM clause.
231:         $criteria->setPrimaryTableName(CouponPeer::TABLE_NAME);
232: 
233:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
234:             $criteria->setDistinct();
235:         }
236: 
237:         if (!$criteria->hasSelectClause()) {
238:             CouponPeer::addSelectColumns($criteria);
239:         }
240: 
241:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
242:         $criteria->setDbName(CouponPeer::DATABASE_NAME); // Set the correct dbName
243: 
244:         if ($con === null) {
245:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
246:         }
247:         // BasePeer returns a PDOStatement
248:         $stmt = BasePeer::doCount($criteria, $con);
249: 
250:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
251:             $count = (int) $row[0];
252:         } else {
253:             $count = 0; // no rows returned; we infer that means 0 matches.
254:         }
255:         $stmt->closeCursor();
256: 
257:         return $count;
258:     }
259:     /**
260:      * Selects one object from the DB.
261:      *
262:      * @param      Criteria $criteria object used to create the SELECT statement.
263:      * @param      PropelPDO $con
264:      * @return                 Coupon
265:      * @throws PropelException Any exceptions caught during processing will be
266:      *       rethrown wrapped into a PropelException.
267:      */
268:     public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
269:     {
270:         $critcopy = clone $criteria;
271:         $critcopy->setLimit(1);
272:         $objects = CouponPeer::doSelect($critcopy, $con);
273:         if ($objects) {
274:             return $objects[0];
275:         }
276: 
277:         return null;
278:     }
279:     /**
280:      * Selects several row from the DB.
281:      *
282:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
283:      * @param      PropelPDO $con
284:      * @return array           Array of selected Objects
285:      * @throws PropelException Any exceptions caught during processing will be
286:      *       rethrown wrapped into a PropelException.
287:      */
288:     public static function doSelect(Criteria $criteria, PropelPDO $con = null)
289:     {
290:         return CouponPeer::populateObjects(CouponPeer::doSelectStmt($criteria, $con));
291:     }
292:     /**
293:      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
294:      *
295:      * Use this method directly if you want to work with an executed statement durirectly (for example
296:      * to perform your own object hydration).
297:      *
298:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
299:      * @param      PropelPDO $con The connection to use
300:      * @throws PropelException Any exceptions caught during processing will be
301:      *       rethrown wrapped into a PropelException.
302:      * @return PDOStatement The executed PDOStatement object.
303:      * @see        BasePeer::doSelect()
304:      */
305:     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
306:     {
307:         if ($con === null) {
308:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
309:         }
310: 
311:         if (!$criteria->hasSelectClause()) {
312:             $criteria = clone $criteria;
313:             CouponPeer::addSelectColumns($criteria);
314:         }
315: 
316:         // Set the correct dbName
317:         $criteria->setDbName(CouponPeer::DATABASE_NAME);
318: 
319:         // BasePeer returns a PDOStatement
320:         return BasePeer::doSelect($criteria, $con);
321:     }
322:     /**
323:      * Adds an object to the instance pool.
324:      *
325:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
326:      * from the database.  In some cases -- especially when you override doSelect*()
327:      * methods in your stub classes -- you may need to explicitly add objects
328:      * to the cache in order to ensure that the same objects are always returned by doSelect*()
329:      * and retrieveByPK*() calls.
330:      *
331:      * @param      Coupon $obj A Coupon object.
332:      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
333:      */
334:     public static function addInstanceToPool($obj, $key = null)
335:     {
336:         if (Propel::isInstancePoolingEnabled()) {
337:             if ($key === null) {
338:                 $key = (string) $obj->getId();
339:             } // if key === null
340:             CouponPeer::$instances[$key] = $obj;
341:         }
342:     }
343: 
344:     /**
345:      * Removes an object from the instance pool.
346:      *
347:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
348:      * from the database.  In some cases -- especially when you override doDelete
349:      * methods in your stub classes -- you may need to explicitly remove objects
350:      * from the cache in order to prevent returning objects that no longer exist.
351:      *
352:      * @param      mixed $value A Coupon object or a primary key value.
353:      *
354:      * @return void
355:      * @throws PropelException - if the value is invalid.
356:      */
357:     public static function removeInstanceFromPool($value)
358:     {
359:         if (Propel::isInstancePoolingEnabled() && $value !== null) {
360:             if (is_object($value) && $value instanceof Coupon) {
361:                 $key = (string) $value->getId();
362:             } elseif (is_scalar($value)) {
363:                 // assume we've been passed a primary key
364:                 $key = (string) $value;
365:             } else {
366:                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Coupon object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
367:                 throw $e;
368:             }
369: 
370:             unset(CouponPeer::$instances[$key]);
371:         }
372:     } // removeInstanceFromPool()
373: 
374:     /**
375:      * 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.
376:      *
377:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
378:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
379:      *
380:      * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
381:      * @return   Coupon Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
382:      * @see        getPrimaryKeyHash()
383:      */
384:     public static function getInstanceFromPool($key)
385:     {
386:         if (Propel::isInstancePoolingEnabled()) {
387:             if (isset(CouponPeer::$instances[$key])) {
388:                 return CouponPeer::$instances[$key];
389:             }
390:         }
391: 
392:         return null; // just to be explicit
393:     }
394: 
395:     /**
396:      * Clear the instance pool.
397:      *
398:      * @return void
399:      */
400:     public static function clearInstancePool()
401:     {
402:         CouponPeer::$instances = array();
403:     }
404: 
405:     /**
406:      * Method to invalidate the instance pool of all tables related to coupon
407:      * by a foreign key with ON DELETE CASCADE
408:      */
409:     public static function clearRelatedInstancePool()
410:     {
411:         // Invalidate objects in CouponRulePeer instance pool,
412:         // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
413:         CouponRulePeer::clearInstancePool();
414:     }
415: 
416:     /**
417:      * 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.
418:      *
419:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
420:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
421:      *
422:      * @param      array $row PropelPDO resultset row.
423:      * @param      int $startcol The 0-based offset for reading from the resultset row.
424:      * @return string A string version of PK or null if the components of primary key in result array are all null.
425:      */
426:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
427:     {
428:         // If the PK cannot be derived from the row, return null.
429:         if ($row[$startcol] === null) {
430:             return null;
431:         }
432: 
433:         return (string) $row[$startcol];
434:     }
435: 
436:     /**
437:      * Retrieves the primary key from the DB resultset row
438:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
439:      * a multi-column primary key, an array of the primary key columns will be returned.
440:      *
441:      * @param      array $row PropelPDO resultset row.
442:      * @param      int $startcol The 0-based offset for reading from the resultset row.
443:      * @return mixed The primary key of the row
444:      */
445:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
446:     {
447: 
448:         return (int) $row[$startcol];
449:     }
450: 
451:     /**
452:      * The returned array will contain objects of the default type or
453:      * objects that inherit from the default.
454:      *
455:      * @throws PropelException Any exceptions caught during processing will be
456:      *       rethrown wrapped into a PropelException.
457:      */
458:     public static function populateObjects(PDOStatement $stmt)
459:     {
460:         $results = array();
461: 
462:         // set the class once to avoid overhead in the loop
463:         $cls = CouponPeer::getOMClass();
464:         // populate the object(s)
465:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
466:             $key = CouponPeer::getPrimaryKeyHashFromRow($row, 0);
467:             if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) {
468:                 // We no longer rehydrate the object, since this can cause data loss.
469:                 // See http://www.propelorm.org/ticket/509
470:                 // $obj->hydrate($row, 0, true); // rehydrate
471:                 $results[] = $obj;
472:             } else {
473:                 $obj = new $cls();
474:                 $obj->hydrate($row);
475:                 $results[] = $obj;
476:                 CouponPeer::addInstanceToPool($obj, $key);
477:             } // if key exists
478:         }
479:         $stmt->closeCursor();
480: 
481:         return $results;
482:     }
483:     /**
484:      * Populates an object of the default type or an object that inherit from the default.
485:      *
486:      * @param      array $row PropelPDO resultset row.
487:      * @param      int $startcol The 0-based offset for reading from the resultset row.
488:      * @throws PropelException Any exceptions caught during processing will be
489:      *       rethrown wrapped into a PropelException.
490:      * @return array (Coupon object, last column rank)
491:      */
492:     public static function populateObject($row, $startcol = 0)
493:     {
494:         $key = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol);
495:         if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) {
496:             // We no longer rehydrate the object, since this can cause data loss.
497:             // See http://www.propelorm.org/ticket/509
498:             // $obj->hydrate($row, $startcol, true); // rehydrate
499:             $col = $startcol + CouponPeer::NUM_HYDRATE_COLUMNS;
500:         } else {
501:             $cls = CouponPeer::OM_CLASS;
502:             $obj = new $cls();
503:             $col = $obj->hydrate($row, $startcol);
504:             CouponPeer::addInstanceToPool($obj, $key);
505:         }
506: 
507:         return array($obj, $col);
508:     }
509: 
510:     /**
511:      * Returns the TableMap related to this peer.
512:      * This method is not needed for general use but a specific application could have a need.
513:      * @return TableMap
514:      * @throws PropelException Any exceptions caught during processing will be
515:      *       rethrown wrapped into a PropelException.
516:      */
517:     public static function getTableMap()
518:     {
519:         return Propel::getDatabaseMap(CouponPeer::DATABASE_NAME)->getTable(CouponPeer::TABLE_NAME);
520:     }
521: 
522:     /**
523:      * Add a TableMap instance to the database for this peer class.
524:      */
525:     public static function buildTableMap()
526:     {
527:       $dbMap = Propel::getDatabaseMap(BaseCouponPeer::DATABASE_NAME);
528:       if (!$dbMap->hasTable(BaseCouponPeer::TABLE_NAME)) {
529:         $dbMap->addTableObject(new CouponTableMap());
530:       }
531:     }
532: 
533:     /**
534:      * The class that the Peer will make instances of.
535:      *
536:      *
537:      * @return string ClassName
538:      */
539:     public static function getOMClass()
540:     {
541:         return CouponPeer::OM_CLASS;
542:     }
543: 
544:     /**
545:      * Performs an INSERT on the database, given a Coupon or Criteria object.
546:      *
547:      * @param      mixed $values Criteria or Coupon object containing data that is used to create the INSERT statement.
548:      * @param      PropelPDO $con the PropelPDO connection to use
549:      * @return mixed           The new primary key.
550:      * @throws PropelException Any exceptions caught during processing will be
551:      *       rethrown wrapped into a PropelException.
552:      */
553:     public static function doInsert($values, PropelPDO $con = null)
554:     {
555:         if ($con === null) {
556:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
557:         }
558: 
559:         if ($values instanceof Criteria) {
560:             $criteria = clone $values; // rename for clarity
561:         } else {
562:             $criteria = $values->buildCriteria(); // build Criteria from Coupon object
563:         }
564: 
565:         if ($criteria->containsKey(CouponPeer::ID) && $criteria->keyContainsValue(CouponPeer::ID) ) {
566:             throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponPeer::ID.')');
567:         }
568: 
569: 
570:         // Set the correct dbName
571:         $criteria->setDbName(CouponPeer::DATABASE_NAME);
572: 
573:         try {
574:             // use transaction because $criteria could contain info
575:             // for more than one table (I guess, conceivably)
576:             $con->beginTransaction();
577:             $pk = BasePeer::doInsert($criteria, $con);
578:             $con->commit();
579:         } catch (PropelException $e) {
580:             $con->rollBack();
581:             throw $e;
582:         }
583: 
584:         return $pk;
585:     }
586: 
587:     /**
588:      * Performs an UPDATE on the database, given a Coupon or Criteria object.
589:      *
590:      * @param      mixed $values Criteria or Coupon object containing data that is used to create the UPDATE statement.
591:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
592:      * @return int             The number of affected rows (if supported by underlying database driver).
593:      * @throws PropelException Any exceptions caught during processing will be
594:      *       rethrown wrapped into a PropelException.
595:      */
596:     public static function doUpdate($values, PropelPDO $con = null)
597:     {
598:         if ($con === null) {
599:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
600:         }
601: 
602:         $selectCriteria = new Criteria(CouponPeer::DATABASE_NAME);
603: 
604:         if ($values instanceof Criteria) {
605:             $criteria = clone $values; // rename for clarity
606: 
607:             $comparison = $criteria->getComparison(CouponPeer::ID);
608:             $value = $criteria->remove(CouponPeer::ID);
609:             if ($value) {
610:                 $selectCriteria->add(CouponPeer::ID, $value, $comparison);
611:             } else {
612:                 $selectCriteria->setPrimaryTableName(CouponPeer::TABLE_NAME);
613:             }
614: 
615:         } else { // $values is Coupon object
616:             $criteria = $values->buildCriteria(); // gets full criteria
617:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
618:         }
619: 
620:         // set the correct dbName
621:         $criteria->setDbName(CouponPeer::DATABASE_NAME);
622: 
623:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
624:     }
625: 
626:     /**
627:      * Deletes all rows from the coupon table.
628:      *
629:      * @param      PropelPDO $con the connection to use
630:      * @return int             The number of affected rows (if supported by underlying database driver).
631:      * @throws PropelException
632:      */
633:     public static function doDeleteAll(PropelPDO $con = null)
634:     {
635:         if ($con === null) {
636:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
637:         }
638:         $affectedRows = 0; // initialize var to track total num of affected rows
639:         try {
640:             // use transaction because $criteria could contain info
641:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
642:             $con->beginTransaction();
643:             $affectedRows += BasePeer::doDeleteAll(CouponPeer::TABLE_NAME, $con, CouponPeer::DATABASE_NAME);
644:             // Because this db requires some delete cascade/set null emulation, we have to
645:             // clear the cached instance *after* the emulation has happened (since
646:             // instances get re-added by the select statement contained therein).
647:             CouponPeer::clearInstancePool();
648:             CouponPeer::clearRelatedInstancePool();
649:             $con->commit();
650: 
651:             return $affectedRows;
652:         } catch (PropelException $e) {
653:             $con->rollBack();
654:             throw $e;
655:         }
656:     }
657: 
658:     /**
659:      * Performs a DELETE on the database, given a Coupon or Criteria object OR a primary key value.
660:      *
661:      * @param      mixed $values Criteria or Coupon object or primary key or array of primary keys
662:      *              which is used to create the DELETE statement
663:      * @param      PropelPDO $con the connection to use
664:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
665:      *              if supported by native driver or if emulated using Propel.
666:      * @throws PropelException Any exceptions caught during processing will be
667:      *       rethrown wrapped into a PropelException.
668:      */
669:      public static function doDelete($values, PropelPDO $con = null)
670:      {
671:         if ($con === null) {
672:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
673:         }
674: 
675:         if ($values instanceof Criteria) {
676:             // invalidate the cache for all objects of this type, since we have no
677:             // way of knowing (without running a query) what objects should be invalidated
678:             // from the cache based on this Criteria.
679:             CouponPeer::clearInstancePool();
680:             // rename for clarity
681:             $criteria = clone $values;
682:         } elseif ($values instanceof Coupon) { // it's a model object
683:             // invalidate the cache for this single object
684:             CouponPeer::removeInstanceFromPool($values);
685:             // create criteria based on pk values
686:             $criteria = $values->buildPkeyCriteria();
687:         } else { // it's a primary key, or an array of pks
688:             $criteria = new Criteria(CouponPeer::DATABASE_NAME);
689:             $criteria->add(CouponPeer::ID, (array) $values, Criteria::IN);
690:             // invalidate the cache for this object(s)
691:             foreach ((array) $values as $singleval) {
692:                 CouponPeer::removeInstanceFromPool($singleval);
693:             }
694:         }
695: 
696:         // Set the correct dbName
697:         $criteria->setDbName(CouponPeer::DATABASE_NAME);
698: 
699:         $affectedRows = 0; // initialize var to track total num of affected rows
700: 
701:         try {
702:             // use transaction because $criteria could contain info
703:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
704:             $con->beginTransaction();
705: 
706:             $affectedRows += BasePeer::doDelete($criteria, $con);
707:             CouponPeer::clearRelatedInstancePool();
708:             $con->commit();
709: 
710:             return $affectedRows;
711:         } catch (PropelException $e) {
712:             $con->rollBack();
713:             throw $e;
714:         }
715:     }
716: 
717:     /**
718:      * Validates all modified columns of given Coupon object.
719:      * If parameter $columns is either a single column name or an array of column names
720:      * than only those columns are validated.
721:      *
722:      * NOTICE: This does not apply to primary or foreign keys for now.
723:      *
724:      * @param      Coupon $obj The object to validate.
725:      * @param      mixed $cols Column name or array of column names.
726:      *
727:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
728:      */
729:     public static function doValidate($obj, $cols = null)
730:     {
731:         $columns = array();
732: 
733:         if ($cols) {
734:             $dbMap = Propel::getDatabaseMap(CouponPeer::DATABASE_NAME);
735:             $tableMap = $dbMap->getTable(CouponPeer::TABLE_NAME);
736: 
737:             if (! is_array($cols)) {
738:                 $cols = array($cols);
739:             }
740: 
741:             foreach ($cols as $colName) {
742:                 if ($tableMap->hasColumn($colName)) {
743:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
744:                     $columns[$colName] = $obj->$get();
745:                 }
746:             }
747:         } else {
748: 
749:         }
750: 
751:         return BasePeer::doValidate(CouponPeer::DATABASE_NAME, CouponPeer::TABLE_NAME, $columns);
752:     }
753: 
754:     /**
755:      * Retrieve a single object by pkey.
756:      *
757:      * @param      int $pk the primary key.
758:      * @param      PropelPDO $con the connection to use
759:      * @return Coupon
760:      */
761:     public static function retrieveByPK($pk, PropelPDO $con = null)
762:     {
763: 
764:         if (null !== ($obj = CouponPeer::getInstanceFromPool((string) $pk))) {
765:             return $obj;
766:         }
767: 
768:         if ($con === null) {
769:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
770:         }
771: 
772:         $criteria = new Criteria(CouponPeer::DATABASE_NAME);
773:         $criteria->add(CouponPeer::ID, $pk);
774: 
775:         $v = CouponPeer::doSelect($criteria, $con);
776: 
777:         return !empty($v) > 0 ? $v[0] : null;
778:     }
779: 
780:     /**
781:      * Retrieve multiple objects by pkey.
782:      *
783:      * @param      array $pks List of primary keys
784:      * @param      PropelPDO $con the connection to use
785:      * @return Coupon[]
786:      * @throws PropelException Any exceptions caught during processing will be
787:      *       rethrown wrapped into a PropelException.
788:      */
789:     public static function retrieveByPKs($pks, PropelPDO $con = null)
790:     {
791:         if ($con === null) {
792:             $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ);
793:         }
794: 
795:         $objs = null;
796:         if (empty($pks)) {
797:             $objs = array();
798:         } else {
799:             $criteria = new Criteria(CouponPeer::DATABASE_NAME);
800:             $criteria->add(CouponPeer::ID, $pks, Criteria::IN);
801:             $objs = CouponPeer::doSelect($criteria, $con);
802:         }
803: 
804:         return $objs;
805:     }
806: 
807: } // BaseCouponPeer
808: 
809: // This is the static code needed to register the TableMap for this table with the main Propel class.
810: //
811: BaseCouponPeer::buildTableMap();
812: 
813: 
thelia API documentation generated by ApiGen 2.8.0