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