Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

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