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