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\GroupModule;
13: use Thelia\Model\GroupModulePeer;
14: use Thelia\Model\GroupPeer;
15: use Thelia\Model\ModulePeer;
16: use Thelia\Model\map\GroupModuleTableMap;
17:
18: /**
19: * Base static class for performing query and update operations on the 'group_module' table.
20: *
21: *
22: *
23: * @package propel.generator.Thelia.Model.om
24: */
25: abstract class BaseGroupModulePeer
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 = 'group_module';
33:
34: /** the related Propel class for this table */
35: const OM_CLASS = 'Thelia\\Model\\GroupModule';
36:
37: /** the related TableMap class for this table */
38: const TM_CLASS = 'GroupModuleTableMap';
39:
40: /** The total number of columns. */
41: const NUM_COLUMNS = 6;
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 = 6;
48:
49: /** the column name for the id field */
50: const ID = 'group_module.id';
51:
52: /** the column name for the group_id field */
53: const GROUP_ID = 'group_module.group_id';
54:
55: /** the column name for the module_id field */
56: const MODULE_ID = 'group_module.module_id';
57:
58: /** the column name for the access field */
59: const ACCESS = 'group_module.access';
60:
61: /** the column name for the created_at field */
62: const CREATED_AT = 'group_module.created_at';
63:
64: /** the column name for the updated_at field */
65: const UPDATED_AT = 'group_module.updated_at';
66:
67: /** The default string format for model objects of the related table **/
68: const DEFAULT_STRING_FORMAT = 'YAML';
69:
70: /**
71: * An identiy map to hold any loaded instances of GroupModule objects.
72: * This must be public so that other peer classes can access this when hydrating from JOIN
73: * queries.
74: * @var array GroupModule[]
75: */
76: public static $instances = array();
77:
78:
79: /**
80: * holds an array of fieldnames
81: *
82: * first dimension keys are the type constants
83: * e.g. GroupModulePeer::$fieldNames[GroupModulePeer::TYPE_PHPNAME][0] = 'Id'
84: */
85: protected static $fieldNames = array (
86: BasePeer::TYPE_PHPNAME => array ('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ),
87: BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ),
88: BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID, GroupModulePeer::GROUP_ID, GroupModulePeer::MODULE_ID, GroupModulePeer::ACCESS, GroupModulePeer::CREATED_AT, GroupModulePeer::UPDATED_AT, ),
89: BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ),
90: BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ),
91: BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
92: );
93:
94: /**
95: * holds an array of keys for quick access to the fieldnames array
96: *
97: * first dimension keys are the type constants
98: * e.g. GroupModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
99: */
100: protected static $fieldKeys = array (
101: BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
102: BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
103: BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID => 0, GroupModulePeer::GROUP_ID => 1, GroupModulePeer::MODULE_ID => 2, GroupModulePeer::ACCESS => 3, GroupModulePeer::CREATED_AT => 4, GroupModulePeer::UPDATED_AT => 5, ),
104: BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
105: BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ),
106: BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
107: );
108:
109: /**
110: * Translates a fieldname to another type
111: *
112: * @param string $name field name
113: * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
114: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
115: * @param string $toType One of the class type constants
116: * @return string translated name of the field.
117: * @throws PropelException - if the specified name could not be found in the fieldname mappings.
118: */
119: public static function translateFieldName($name, $fromType, $toType)
120: {
121: $toNames = GroupModulePeer::getFieldNames($toType);
122: $key = isset(GroupModulePeer::$fieldKeys[$fromType][$name]) ? GroupModulePeer::$fieldKeys[$fromType][$name] : null;
123: if ($key === null) {
124: throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupModulePeer::$fieldKeys[$fromType], true));
125: }
126:
127: return $toNames[$key];
128: }
129:
130: /**
131: * Returns an array of field names.
132: *
133: * @param string $type The type of fieldnames to return:
134: * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
135: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
136: * @return array A list of field names
137: * @throws PropelException - if the type is not valid.
138: */
139: public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
140: {
141: if (!array_key_exists($type, GroupModulePeer::$fieldNames)) {
142: 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.');
143: }
144:
145: return GroupModulePeer::$fieldNames[$type];
146: }
147:
148: /**
149: * Convenience method which changes table.column to alias.column.
150: *
151: * Using this method you can maintain SQL abstraction while using column aliases.
152: * <code>
153: * $c->addAlias("alias1", TablePeer::TABLE_NAME);
154: * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
155: * </code>
156: * @param string $alias The alias for the current table.
157: * @param string $column The column name for current table. (i.e. GroupModulePeer::COLUMN_NAME).
158: * @return string
159: */
160: public static function alias($alias, $column)
161: {
162: return str_replace(GroupModulePeer::TABLE_NAME.'.', $alias.'.', $column);
163: }
164:
165: /**
166: * Add all the columns needed to create a new object.
167: *
168: * Note: any columns that were marked with lazyLoad="true" in the
169: * XML schema will not be added to the select list and only loaded
170: * on demand.
171: *
172: * @param Criteria $criteria object containing the columns to add.
173: * @param string $alias optional table alias
174: * @throws PropelException Any exceptions caught during processing will be
175: * rethrown wrapped into a PropelException.
176: */
177: public static function addSelectColumns(Criteria $criteria, $alias = null)
178: {
179: if (null === $alias) {
180: $criteria->addSelectColumn(GroupModulePeer::ID);
181: $criteria->addSelectColumn(GroupModulePeer::GROUP_ID);
182: $criteria->addSelectColumn(GroupModulePeer::MODULE_ID);
183: $criteria->addSelectColumn(GroupModulePeer::ACCESS);
184: $criteria->addSelectColumn(GroupModulePeer::CREATED_AT);
185: $criteria->addSelectColumn(GroupModulePeer::UPDATED_AT);
186: } else {
187: $criteria->addSelectColumn($alias . '.id');
188: $criteria->addSelectColumn($alias . '.group_id');
189: $criteria->addSelectColumn($alias . '.module_id');
190: $criteria->addSelectColumn($alias . '.access');
191: $criteria->addSelectColumn($alias . '.created_at');
192: $criteria->addSelectColumn($alias . '.updated_at');
193: }
194: }
195:
196: /**
197: * Returns the number of rows matching criteria.
198: *
199: * @param Criteria $criteria
200: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
201: * @param PropelPDO $con
202: * @return int Number of matching rows.
203: */
204: public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
205: {
206: // we may modify criteria, so copy it first
207: $criteria = clone $criteria;
208:
209: // We need to set the primary table name, since in the case that there are no WHERE columns
210: // it will be impossible for the BasePeer::createSelectSql() method to determine which
211: // tables go into the FROM clause.
212: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
213:
214: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
215: $criteria->setDistinct();
216: }
217:
218: if (!$criteria->hasSelectClause()) {
219: GroupModulePeer::addSelectColumns($criteria);
220: }
221:
222: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
223: $criteria->setDbName(GroupModulePeer::DATABASE_NAME); // Set the correct dbName
224:
225: if ($con === null) {
226: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
227: }
228: // BasePeer returns a PDOStatement
229: $stmt = BasePeer::doCount($criteria, $con);
230:
231: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
232: $count = (int) $row[0];
233: } else {
234: $count = 0; // no rows returned; we infer that means 0 matches.
235: }
236: $stmt->closeCursor();
237:
238: return $count;
239: }
240: /**
241: * Selects one object from the DB.
242: *
243: * @param Criteria $criteria object used to create the SELECT statement.
244: * @param PropelPDO $con
245: * @return GroupModule
246: * @throws PropelException Any exceptions caught during processing will be
247: * rethrown wrapped into a PropelException.
248: */
249: public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
250: {
251: $critcopy = clone $criteria;
252: $critcopy->setLimit(1);
253: $objects = GroupModulePeer::doSelect($critcopy, $con);
254: if ($objects) {
255: return $objects[0];
256: }
257:
258: return null;
259: }
260: /**
261: * Selects several row from the DB.
262: *
263: * @param Criteria $criteria The Criteria object used to build the SELECT statement.
264: * @param PropelPDO $con
265: * @return array Array of selected Objects
266: * @throws PropelException Any exceptions caught during processing will be
267: * rethrown wrapped into a PropelException.
268: */
269: public static function doSelect(Criteria $criteria, PropelPDO $con = null)
270: {
271: return GroupModulePeer::populateObjects(GroupModulePeer::doSelectStmt($criteria, $con));
272: }
273: /**
274: * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
275: *
276: * Use this method directly if you want to work with an executed statement directly (for example
277: * to perform your own object hydration).
278: *
279: * @param Criteria $criteria The Criteria object used to build the SELECT statement.
280: * @param PropelPDO $con The connection to use
281: * @throws PropelException Any exceptions caught during processing will be
282: * rethrown wrapped into a PropelException.
283: * @return PDOStatement The executed PDOStatement object.
284: * @see BasePeer::doSelect()
285: */
286: public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
287: {
288: if ($con === null) {
289: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
290: }
291:
292: if (!$criteria->hasSelectClause()) {
293: $criteria = clone $criteria;
294: GroupModulePeer::addSelectColumns($criteria);
295: }
296:
297: // Set the correct dbName
298: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
299:
300: // BasePeer returns a PDOStatement
301: return BasePeer::doSelect($criteria, $con);
302: }
303: /**
304: * Adds an object to the instance pool.
305: *
306: * Propel keeps cached copies of objects in an instance pool when they are retrieved
307: * from the database. In some cases -- especially when you override doSelect*()
308: * methods in your stub classes -- you may need to explicitly add objects
309: * to the cache in order to ensure that the same objects are always returned by doSelect*()
310: * and retrieveByPK*() calls.
311: *
312: * @param GroupModule $obj A GroupModule object.
313: * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
314: */
315: public static function addInstanceToPool($obj, $key = null)
316: {
317: if (Propel::isInstancePoolingEnabled()) {
318: if ($key === null) {
319: $key = (string) $obj->getId();
320: } // if key === null
321: GroupModulePeer::$instances[$key] = $obj;
322: }
323: }
324:
325: /**
326: * Removes an object from the instance pool.
327: *
328: * Propel keeps cached copies of objects in an instance pool when they are retrieved
329: * from the database. In some cases -- especially when you override doDelete
330: * methods in your stub classes -- you may need to explicitly remove objects
331: * from the cache in order to prevent returning objects that no longer exist.
332: *
333: * @param mixed $value A GroupModule object or a primary key value.
334: *
335: * @return void
336: * @throws PropelException - if the value is invalid.
337: */
338: public static function removeInstanceFromPool($value)
339: {
340: if (Propel::isInstancePoolingEnabled() && $value !== null) {
341: if (is_object($value) && $value instanceof GroupModule) {
342: $key = (string) $value->getId();
343: } elseif (is_scalar($value)) {
344: // assume we've been passed a primary key
345: $key = (string) $value;
346: } else {
347: $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupModule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
348: throw $e;
349: }
350:
351: unset(GroupModulePeer::$instances[$key]);
352: }
353: } // removeInstanceFromPool()
354:
355: /**
356: * 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.
357: *
358: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
359: * a multi-column primary key, a serialize()d version of the primary key will be returned.
360: *
361: * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
362: * @return GroupModule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
363: * @see getPrimaryKeyHash()
364: */
365: public static function getInstanceFromPool($key)
366: {
367: if (Propel::isInstancePoolingEnabled()) {
368: if (isset(GroupModulePeer::$instances[$key])) {
369: return GroupModulePeer::$instances[$key];
370: }
371: }
372:
373: return null; // just to be explicit
374: }
375:
376: /**
377: * Clear the instance pool.
378: *
379: * @return void
380: */
381: public static function clearInstancePool($and_clear_all_references = false)
382: {
383: if ($and_clear_all_references)
384: {
385: foreach (GroupModulePeer::$instances as $instance)
386: {
387: $instance->clearAllReferences(true);
388: }
389: }
390: GroupModulePeer::$instances = array();
391: }
392:
393: /**
394: * Method to invalidate the instance pool of all tables related to group_module
395: * by a foreign key with ON DELETE CASCADE
396: */
397: public static function clearRelatedInstancePool()
398: {
399: }
400:
401: /**
402: * 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.
403: *
404: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
405: * a multi-column primary key, a serialize()d version of the primary key will be returned.
406: *
407: * @param array $row PropelPDO resultset row.
408: * @param int $startcol The 0-based offset for reading from the resultset row.
409: * @return string A string version of PK or null if the components of primary key in result array are all null.
410: */
411: public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
412: {
413: // If the PK cannot be derived from the row, return null.
414: if ($row[$startcol] === null) {
415: return null;
416: }
417:
418: return (string) $row[$startcol];
419: }
420:
421: /**
422: * Retrieves the primary key from the DB resultset row
423: * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
424: * a multi-column primary key, an array of the primary key columns will be returned.
425: *
426: * @param array $row PropelPDO resultset row.
427: * @param int $startcol The 0-based offset for reading from the resultset row.
428: * @return mixed The primary key of the row
429: */
430: public static function getPrimaryKeyFromRow($row, $startcol = 0)
431: {
432:
433: return (int) $row[$startcol];
434: }
435:
436: /**
437: * The returned array will contain objects of the default type or
438: * objects that inherit from the default.
439: *
440: * @throws PropelException Any exceptions caught during processing will be
441: * rethrown wrapped into a PropelException.
442: */
443: public static function populateObjects(PDOStatement $stmt)
444: {
445: $results = array();
446:
447: // set the class once to avoid overhead in the loop
448: $cls = GroupModulePeer::getOMClass();
449: // populate the object(s)
450: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
451: $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
452: if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) {
453: // We no longer rehydrate the object, since this can cause data loss.
454: // See http://www.propelorm.org/ticket/509
455: // $obj->hydrate($row, 0, true); // rehydrate
456: $results[] = $obj;
457: } else {
458: $obj = new $cls();
459: $obj->hydrate($row);
460: $results[] = $obj;
461: GroupModulePeer::addInstanceToPool($obj, $key);
462: } // if key exists
463: }
464: $stmt->closeCursor();
465:
466: return $results;
467: }
468: /**
469: * Populates an object of the default type or an object that inherit from the default.
470: *
471: * @param array $row PropelPDO resultset row.
472: * @param int $startcol The 0-based offset for reading from the resultset row.
473: * @throws PropelException Any exceptions caught during processing will be
474: * rethrown wrapped into a PropelException.
475: * @return array (GroupModule object, last column rank)
476: */
477: public static function populateObject($row, $startcol = 0)
478: {
479: $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
480: if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) {
481: // We no longer rehydrate the object, since this can cause data loss.
482: // See http://www.propelorm.org/ticket/509
483: // $obj->hydrate($row, $startcol, true); // rehydrate
484: $col = $startcol + GroupModulePeer::NUM_HYDRATE_COLUMNS;
485: } else {
486: $cls = GroupModulePeer::OM_CLASS;
487: $obj = new $cls();
488: $col = $obj->hydrate($row, $startcol);
489: GroupModulePeer::addInstanceToPool($obj, $key);
490: }
491:
492: return array($obj, $col);
493: }
494:
495:
496: /**
497: * Returns the number of rows matching criteria, joining the related Group table
498: *
499: * @param Criteria $criteria
500: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
501: * @param PropelPDO $con
502: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
503: * @return int Number of matching rows.
504: */
505: public static function doCountJoinGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
506: {
507: // we're going to modify criteria, so copy it first
508: $criteria = clone $criteria;
509:
510: // We need to set the primary table name, since in the case that there are no WHERE columns
511: // it will be impossible for the BasePeer::createSelectSql() method to determine which
512: // tables go into the FROM clause.
513: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
514:
515: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
516: $criteria->setDistinct();
517: }
518:
519: if (!$criteria->hasSelectClause()) {
520: GroupModulePeer::addSelectColumns($criteria);
521: }
522:
523: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
524:
525: // Set the correct dbName
526: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
527:
528: if ($con === null) {
529: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
530: }
531:
532: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
533:
534: $stmt = BasePeer::doCount($criteria, $con);
535:
536: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
537: $count = (int) $row[0];
538: } else {
539: $count = 0; // no rows returned; we infer that means 0 matches.
540: }
541: $stmt->closeCursor();
542:
543: return $count;
544: }
545:
546:
547: /**
548: * Returns the number of rows matching criteria, joining the related Module table
549: *
550: * @param Criteria $criteria
551: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
552: * @param PropelPDO $con
553: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
554: * @return int Number of matching rows.
555: */
556: public static function doCountJoinModule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
557: {
558: // we're going to modify criteria, so copy it first
559: $criteria = clone $criteria;
560:
561: // We need to set the primary table name, since in the case that there are no WHERE columns
562: // it will be impossible for the BasePeer::createSelectSql() method to determine which
563: // tables go into the FROM clause.
564: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
565:
566: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
567: $criteria->setDistinct();
568: }
569:
570: if (!$criteria->hasSelectClause()) {
571: GroupModulePeer::addSelectColumns($criteria);
572: }
573:
574: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
575:
576: // Set the correct dbName
577: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
578:
579: if ($con === null) {
580: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
581: }
582:
583: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
584:
585: $stmt = BasePeer::doCount($criteria, $con);
586:
587: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
588: $count = (int) $row[0];
589: } else {
590: $count = 0; // no rows returned; we infer that means 0 matches.
591: }
592: $stmt->closeCursor();
593:
594: return $count;
595: }
596:
597:
598: /**
599: * Selects a collection of GroupModule objects pre-filled with their Group objects.
600: * @param Criteria $criteria
601: * @param PropelPDO $con
602: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
603: * @return array Array of GroupModule objects.
604: * @throws PropelException Any exceptions caught during processing will be
605: * rethrown wrapped into a PropelException.
606: */
607: public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
608: {
609: $criteria = clone $criteria;
610:
611: // Set the correct dbName if it has not been overridden
612: if ($criteria->getDbName() == Propel::getDefaultDB()) {
613: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
614: }
615:
616: GroupModulePeer::addSelectColumns($criteria);
617: $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS;
618: GroupPeer::addSelectColumns($criteria);
619:
620: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
621:
622: $stmt = BasePeer::doSelect($criteria, $con);
623: $results = array();
624:
625: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
626: $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
627: if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
628: // We no longer rehydrate the object, since this can cause data loss.
629: // See http://www.propelorm.org/ticket/509
630: // $obj1->hydrate($row, 0, true); // rehydrate
631: } else {
632:
633: $cls = GroupModulePeer::getOMClass();
634:
635: $obj1 = new $cls();
636: $obj1->hydrate($row);
637: GroupModulePeer::addInstanceToPool($obj1, $key1);
638: } // if $obj1 already loaded
639:
640: $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol);
641: if ($key2 !== null) {
642: $obj2 = GroupPeer::getInstanceFromPool($key2);
643: if (!$obj2) {
644:
645: $cls = GroupPeer::getOMClass();
646:
647: $obj2 = new $cls();
648: $obj2->hydrate($row, $startcol);
649: GroupPeer::addInstanceToPool($obj2, $key2);
650: } // if obj2 already loaded
651:
652: // Add the $obj1 (GroupModule) to $obj2 (Group)
653: $obj2->addGroupModule($obj1);
654:
655: } // if joined row was not null
656:
657: $results[] = $obj1;
658: }
659: $stmt->closeCursor();
660:
661: return $results;
662: }
663:
664:
665: /**
666: * Selects a collection of GroupModule objects pre-filled with their Module objects.
667: * @param Criteria $criteria
668: * @param PropelPDO $con
669: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
670: * @return array Array of GroupModule objects.
671: * @throws PropelException Any exceptions caught during processing will be
672: * rethrown wrapped into a PropelException.
673: */
674: public static function doSelectJoinModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
675: {
676: $criteria = clone $criteria;
677:
678: // Set the correct dbName if it has not been overridden
679: if ($criteria->getDbName() == Propel::getDefaultDB()) {
680: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
681: }
682:
683: GroupModulePeer::addSelectColumns($criteria);
684: $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS;
685: ModulePeer::addSelectColumns($criteria);
686:
687: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
688:
689: $stmt = BasePeer::doSelect($criteria, $con);
690: $results = array();
691:
692: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
693: $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
694: if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
695: // We no longer rehydrate the object, since this can cause data loss.
696: // See http://www.propelorm.org/ticket/509
697: // $obj1->hydrate($row, 0, true); // rehydrate
698: } else {
699:
700: $cls = GroupModulePeer::getOMClass();
701:
702: $obj1 = new $cls();
703: $obj1->hydrate($row);
704: GroupModulePeer::addInstanceToPool($obj1, $key1);
705: } // if $obj1 already loaded
706:
707: $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol);
708: if ($key2 !== null) {
709: $obj2 = ModulePeer::getInstanceFromPool($key2);
710: if (!$obj2) {
711:
712: $cls = ModulePeer::getOMClass();
713:
714: $obj2 = new $cls();
715: $obj2->hydrate($row, $startcol);
716: ModulePeer::addInstanceToPool($obj2, $key2);
717: } // if obj2 already loaded
718:
719: // Add the $obj1 (GroupModule) to $obj2 (Module)
720: $obj2->addGroupModule($obj1);
721:
722: } // if joined row was not null
723:
724: $results[] = $obj1;
725: }
726: $stmt->closeCursor();
727:
728: return $results;
729: }
730:
731:
732: /**
733: * Returns the number of rows matching criteria, joining all related tables
734: *
735: * @param Criteria $criteria
736: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
737: * @param PropelPDO $con
738: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
739: * @return int Number of matching rows.
740: */
741: public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
742: {
743: // we're going to modify criteria, so copy it first
744: $criteria = clone $criteria;
745:
746: // We need to set the primary table name, since in the case that there are no WHERE columns
747: // it will be impossible for the BasePeer::createSelectSql() method to determine which
748: // tables go into the FROM clause.
749: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
750:
751: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
752: $criteria->setDistinct();
753: }
754:
755: if (!$criteria->hasSelectClause()) {
756: GroupModulePeer::addSelectColumns($criteria);
757: }
758:
759: $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
760:
761: // Set the correct dbName
762: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
763:
764: if ($con === null) {
765: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
766: }
767:
768: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
769:
770: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
771:
772: $stmt = BasePeer::doCount($criteria, $con);
773:
774: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
775: $count = (int) $row[0];
776: } else {
777: $count = 0; // no rows returned; we infer that means 0 matches.
778: }
779: $stmt->closeCursor();
780:
781: return $count;
782: }
783:
784: /**
785: * Selects a collection of GroupModule objects pre-filled with all related objects.
786: *
787: * @param Criteria $criteria
788: * @param PropelPDO $con
789: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
790: * @return array Array of GroupModule objects.
791: * @throws PropelException Any exceptions caught during processing will be
792: * rethrown wrapped into a PropelException.
793: */
794: public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
795: {
796: $criteria = clone $criteria;
797:
798: // Set the correct dbName if it has not been overridden
799: if ($criteria->getDbName() == Propel::getDefaultDB()) {
800: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
801: }
802:
803: GroupModulePeer::addSelectColumns($criteria);
804: $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
805:
806: GroupPeer::addSelectColumns($criteria);
807: $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
808:
809: ModulePeer::addSelectColumns($criteria);
810: $startcol4 = $startcol3 + ModulePeer::NUM_HYDRATE_COLUMNS;
811:
812: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
813:
814: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
815:
816: $stmt = BasePeer::doSelect($criteria, $con);
817: $results = array();
818:
819: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
820: $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
821: if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
822: // We no longer rehydrate the object, since this can cause data loss.
823: // See http://www.propelorm.org/ticket/509
824: // $obj1->hydrate($row, 0, true); // rehydrate
825: } else {
826: $cls = GroupModulePeer::getOMClass();
827:
828: $obj1 = new $cls();
829: $obj1->hydrate($row);
830: GroupModulePeer::addInstanceToPool($obj1, $key1);
831: } // if obj1 already loaded
832:
833: // Add objects for joined Group rows
834:
835: $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
836: if ($key2 !== null) {
837: $obj2 = GroupPeer::getInstanceFromPool($key2);
838: if (!$obj2) {
839:
840: $cls = GroupPeer::getOMClass();
841:
842: $obj2 = new $cls();
843: $obj2->hydrate($row, $startcol2);
844: GroupPeer::addInstanceToPool($obj2, $key2);
845: } // if obj2 loaded
846:
847: // Add the $obj1 (GroupModule) to the collection in $obj2 (Group)
848: $obj2->addGroupModule($obj1);
849: } // if joined row not null
850:
851: // Add objects for joined Module rows
852:
853: $key3 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol3);
854: if ($key3 !== null) {
855: $obj3 = ModulePeer::getInstanceFromPool($key3);
856: if (!$obj3) {
857:
858: $cls = ModulePeer::getOMClass();
859:
860: $obj3 = new $cls();
861: $obj3->hydrate($row, $startcol3);
862: ModulePeer::addInstanceToPool($obj3, $key3);
863: } // if obj3 loaded
864:
865: // Add the $obj1 (GroupModule) to the collection in $obj3 (Module)
866: $obj3->addGroupModule($obj1);
867: } // if joined row not null
868:
869: $results[] = $obj1;
870: }
871: $stmt->closeCursor();
872:
873: return $results;
874: }
875:
876:
877: /**
878: * Returns the number of rows matching criteria, joining the related Group table
879: *
880: * @param Criteria $criteria
881: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
882: * @param PropelPDO $con
883: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
884: * @return int Number of matching rows.
885: */
886: public static function doCountJoinAllExceptGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
887: {
888: // we're going to modify criteria, so copy it first
889: $criteria = clone $criteria;
890:
891: // We need to set the primary table name, since in the case that there are no WHERE columns
892: // it will be impossible for the BasePeer::createSelectSql() method to determine which
893: // tables go into the FROM clause.
894: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
895:
896: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
897: $criteria->setDistinct();
898: }
899:
900: if (!$criteria->hasSelectClause()) {
901: GroupModulePeer::addSelectColumns($criteria);
902: }
903:
904: $criteria->clearOrderByColumns(); // ORDER BY should not affect count
905:
906: // Set the correct dbName
907: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
908:
909: if ($con === null) {
910: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
911: }
912:
913: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
914:
915: $stmt = BasePeer::doCount($criteria, $con);
916:
917: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
918: $count = (int) $row[0];
919: } else {
920: $count = 0; // no rows returned; we infer that means 0 matches.
921: }
922: $stmt->closeCursor();
923:
924: return $count;
925: }
926:
927:
928: /**
929: * Returns the number of rows matching criteria, joining the related Module table
930: *
931: * @param Criteria $criteria
932: * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
933: * @param PropelPDO $con
934: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
935: * @return int Number of matching rows.
936: */
937: public static function doCountJoinAllExceptModule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
938: {
939: // we're going to modify criteria, so copy it first
940: $criteria = clone $criteria;
941:
942: // We need to set the primary table name, since in the case that there are no WHERE columns
943: // it will be impossible for the BasePeer::createSelectSql() method to determine which
944: // tables go into the FROM clause.
945: $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
946:
947: if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
948: $criteria->setDistinct();
949: }
950:
951: if (!$criteria->hasSelectClause()) {
952: GroupModulePeer::addSelectColumns($criteria);
953: }
954:
955: $criteria->clearOrderByColumns(); // ORDER BY should not affect count
956:
957: // Set the correct dbName
958: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
959:
960: if ($con === null) {
961: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
962: }
963:
964: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
965:
966: $stmt = BasePeer::doCount($criteria, $con);
967:
968: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
969: $count = (int) $row[0];
970: } else {
971: $count = 0; // no rows returned; we infer that means 0 matches.
972: }
973: $stmt->closeCursor();
974:
975: return $count;
976: }
977:
978:
979: /**
980: * Selects a collection of GroupModule objects pre-filled with all related objects except Group.
981: *
982: * @param Criteria $criteria
983: * @param PropelPDO $con
984: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
985: * @return array Array of GroupModule objects.
986: * @throws PropelException Any exceptions caught during processing will be
987: * rethrown wrapped into a PropelException.
988: */
989: public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
990: {
991: $criteria = clone $criteria;
992:
993: // Set the correct dbName if it has not been overridden
994: // $criteria->getDbName() will return the same object if not set to another value
995: // so == check is okay and faster
996: if ($criteria->getDbName() == Propel::getDefaultDB()) {
997: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
998: }
999:
1000: GroupModulePeer::addSelectColumns($criteria);
1001: $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
1002:
1003: ModulePeer::addSelectColumns($criteria);
1004: $startcol3 = $startcol2 + ModulePeer::NUM_HYDRATE_COLUMNS;
1005:
1006: $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior);
1007:
1008:
1009: $stmt = BasePeer::doSelect($criteria, $con);
1010: $results = array();
1011:
1012: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1013: $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
1014: if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
1015: // We no longer rehydrate the object, since this can cause data loss.
1016: // See http://www.propelorm.org/ticket/509
1017: // $obj1->hydrate($row, 0, true); // rehydrate
1018: } else {
1019: $cls = GroupModulePeer::getOMClass();
1020:
1021: $obj1 = new $cls();
1022: $obj1->hydrate($row);
1023: GroupModulePeer::addInstanceToPool($obj1, $key1);
1024: } // if obj1 already loaded
1025:
1026: // Add objects for joined Module rows
1027:
1028: $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol2);
1029: if ($key2 !== null) {
1030: $obj2 = ModulePeer::getInstanceFromPool($key2);
1031: if (!$obj2) {
1032:
1033: $cls = ModulePeer::getOMClass();
1034:
1035: $obj2 = new $cls();
1036: $obj2->hydrate($row, $startcol2);
1037: ModulePeer::addInstanceToPool($obj2, $key2);
1038: } // if $obj2 already loaded
1039:
1040: // Add the $obj1 (GroupModule) to the collection in $obj2 (Module)
1041: $obj2->addGroupModule($obj1);
1042:
1043: } // if joined row is not null
1044:
1045: $results[] = $obj1;
1046: }
1047: $stmt->closeCursor();
1048:
1049: return $results;
1050: }
1051:
1052:
1053: /**
1054: * Selects a collection of GroupModule objects pre-filled with all related objects except Module.
1055: *
1056: * @param Criteria $criteria
1057: * @param PropelPDO $con
1058: * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
1059: * @return array Array of GroupModule objects.
1060: * @throws PropelException Any exceptions caught during processing will be
1061: * rethrown wrapped into a PropelException.
1062: */
1063: public static function doSelectJoinAllExceptModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1064: {
1065: $criteria = clone $criteria;
1066:
1067: // Set the correct dbName if it has not been overridden
1068: // $criteria->getDbName() will return the same object if not set to another value
1069: // so == check is okay and faster
1070: if ($criteria->getDbName() == Propel::getDefaultDB()) {
1071: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
1072: }
1073:
1074: GroupModulePeer::addSelectColumns($criteria);
1075: $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS;
1076:
1077: GroupPeer::addSelectColumns($criteria);
1078: $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS;
1079:
1080: $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior);
1081:
1082:
1083: $stmt = BasePeer::doSelect($criteria, $con);
1084: $results = array();
1085:
1086: while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
1087: $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0);
1088: if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) {
1089: // We no longer rehydrate the object, since this can cause data loss.
1090: // See http://www.propelorm.org/ticket/509
1091: // $obj1->hydrate($row, 0, true); // rehydrate
1092: } else {
1093: $cls = GroupModulePeer::getOMClass();
1094:
1095: $obj1 = new $cls();
1096: $obj1->hydrate($row);
1097: GroupModulePeer::addInstanceToPool($obj1, $key1);
1098: } // if obj1 already loaded
1099:
1100: // Add objects for joined Group rows
1101:
1102: $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2);
1103: if ($key2 !== null) {
1104: $obj2 = GroupPeer::getInstanceFromPool($key2);
1105: if (!$obj2) {
1106:
1107: $cls = GroupPeer::getOMClass();
1108:
1109: $obj2 = new $cls();
1110: $obj2->hydrate($row, $startcol2);
1111: GroupPeer::addInstanceToPool($obj2, $key2);
1112: } // if $obj2 already loaded
1113:
1114: // Add the $obj1 (GroupModule) to the collection in $obj2 (Group)
1115: $obj2->addGroupModule($obj1);
1116:
1117: } // if joined row is not null
1118:
1119: $results[] = $obj1;
1120: }
1121: $stmt->closeCursor();
1122:
1123: return $results;
1124: }
1125:
1126: /**
1127: * Returns the TableMap related to this peer.
1128: * This method is not needed for general use but a specific application could have a need.
1129: * @return TableMap
1130: * @throws PropelException Any exceptions caught during processing will be
1131: * rethrown wrapped into a PropelException.
1132: */
1133: public static function getTableMap()
1134: {
1135: return Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME)->getTable(GroupModulePeer::TABLE_NAME);
1136: }
1137:
1138: /**
1139: * Add a TableMap instance to the database for this peer class.
1140: */
1141: public static function buildTableMap()
1142: {
1143: $dbMap = Propel::getDatabaseMap(BaseGroupModulePeer::DATABASE_NAME);
1144: if (!$dbMap->hasTable(BaseGroupModulePeer::TABLE_NAME)) {
1145: $dbMap->addTableObject(new GroupModuleTableMap());
1146: }
1147: }
1148:
1149: /**
1150: * The class that the Peer will make instances of.
1151: *
1152: *
1153: * @return string ClassName
1154: */
1155: public static function getOMClass($row = 0, $colnum = 0)
1156: {
1157: return GroupModulePeer::OM_CLASS;
1158: }
1159:
1160: /**
1161: * Performs an INSERT on the database, given a GroupModule or Criteria object.
1162: *
1163: * @param mixed $values Criteria or GroupModule object containing data that is used to create the INSERT statement.
1164: * @param PropelPDO $con the PropelPDO connection to use
1165: * @return mixed The new primary key.
1166: * @throws PropelException Any exceptions caught during processing will be
1167: * rethrown wrapped into a PropelException.
1168: */
1169: public static function doInsert($values, PropelPDO $con = null)
1170: {
1171: if ($con === null) {
1172: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1173: }
1174:
1175: if ($values instanceof Criteria) {
1176: $criteria = clone $values; // rename for clarity
1177: } else {
1178: $criteria = $values->buildCriteria(); // build Criteria from GroupModule object
1179: }
1180:
1181: if ($criteria->containsKey(GroupModulePeer::ID) && $criteria->keyContainsValue(GroupModulePeer::ID) ) {
1182: throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModulePeer::ID.')');
1183: }
1184:
1185:
1186: // Set the correct dbName
1187: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
1188:
1189: try {
1190: // use transaction because $criteria could contain info
1191: // for more than one table (I guess, conceivably)
1192: $con->beginTransaction();
1193: $pk = BasePeer::doInsert($criteria, $con);
1194: $con->commit();
1195: } catch (PropelException $e) {
1196: $con->rollBack();
1197: throw $e;
1198: }
1199:
1200: return $pk;
1201: }
1202:
1203: /**
1204: * Performs an UPDATE on the database, given a GroupModule or Criteria object.
1205: *
1206: * @param mixed $values Criteria or GroupModule object containing data that is used to create the UPDATE statement.
1207: * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
1208: * @return int The number of affected rows (if supported by underlying database driver).
1209: * @throws PropelException Any exceptions caught during processing will be
1210: * rethrown wrapped into a PropelException.
1211: */
1212: public static function doUpdate($values, PropelPDO $con = null)
1213: {
1214: if ($con === null) {
1215: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1216: }
1217:
1218: $selectCriteria = new Criteria(GroupModulePeer::DATABASE_NAME);
1219:
1220: if ($values instanceof Criteria) {
1221: $criteria = clone $values; // rename for clarity
1222:
1223: $comparison = $criteria->getComparison(GroupModulePeer::ID);
1224: $value = $criteria->remove(GroupModulePeer::ID);
1225: if ($value) {
1226: $selectCriteria->add(GroupModulePeer::ID, $value, $comparison);
1227: } else {
1228: $selectCriteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME);
1229: }
1230:
1231: } else { // $values is GroupModule object
1232: $criteria = $values->buildCriteria(); // gets full criteria
1233: $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
1234: }
1235:
1236: // set the correct dbName
1237: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
1238:
1239: return BasePeer::doUpdate($selectCriteria, $criteria, $con);
1240: }
1241:
1242: /**
1243: * Deletes all rows from the group_module table.
1244: *
1245: * @param PropelPDO $con the connection to use
1246: * @return int The number of affected rows (if supported by underlying database driver).
1247: * @throws PropelException
1248: */
1249: public static function doDeleteAll(PropelPDO $con = null)
1250: {
1251: if ($con === null) {
1252: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1253: }
1254: $affectedRows = 0; // initialize var to track total num of affected rows
1255: try {
1256: // use transaction because $criteria could contain info
1257: // for more than one table or we could emulating ON DELETE CASCADE, etc.
1258: $con->beginTransaction();
1259: $affectedRows += BasePeer::doDeleteAll(GroupModulePeer::TABLE_NAME, $con, GroupModulePeer::DATABASE_NAME);
1260: // Because this db requires some delete cascade/set null emulation, we have to
1261: // clear the cached instance *after* the emulation has happened (since
1262: // instances get re-added by the select statement contained therein).
1263: GroupModulePeer::clearInstancePool();
1264: GroupModulePeer::clearRelatedInstancePool();
1265: $con->commit();
1266:
1267: return $affectedRows;
1268: } catch (PropelException $e) {
1269: $con->rollBack();
1270: throw $e;
1271: }
1272: }
1273:
1274: /**
1275: * Performs a DELETE on the database, given a GroupModule or Criteria object OR a primary key value.
1276: *
1277: * @param mixed $values Criteria or GroupModule object or primary key or array of primary keys
1278: * which is used to create the DELETE statement
1279: * @param PropelPDO $con the connection to use
1280: * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
1281: * if supported by native driver or if emulated using Propel.
1282: * @throws PropelException Any exceptions caught during processing will be
1283: * rethrown wrapped into a PropelException.
1284: */
1285: public static function doDelete($values, PropelPDO $con = null)
1286: {
1287: if ($con === null) {
1288: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1289: }
1290:
1291: if ($values instanceof Criteria) {
1292: // invalidate the cache for all objects of this type, since we have no
1293: // way of knowing (without running a query) what objects should be invalidated
1294: // from the cache based on this Criteria.
1295: GroupModulePeer::clearInstancePool();
1296: // rename for clarity
1297: $criteria = clone $values;
1298: } elseif ($values instanceof GroupModule) { // it's a model object
1299: // invalidate the cache for this single object
1300: GroupModulePeer::removeInstanceFromPool($values);
1301: // create criteria based on pk values
1302: $criteria = $values->buildPkeyCriteria();
1303: } else { // it's a primary key, or an array of pks
1304: $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
1305: $criteria->add(GroupModulePeer::ID, (array) $values, Criteria::IN);
1306: // invalidate the cache for this object(s)
1307: foreach ((array) $values as $singleval) {
1308: GroupModulePeer::removeInstanceFromPool($singleval);
1309: }
1310: }
1311:
1312: // Set the correct dbName
1313: $criteria->setDbName(GroupModulePeer::DATABASE_NAME);
1314:
1315: $affectedRows = 0; // initialize var to track total num of affected rows
1316:
1317: try {
1318: // use transaction because $criteria could contain info
1319: // for more than one table or we could emulating ON DELETE CASCADE, etc.
1320: $con->beginTransaction();
1321:
1322: $affectedRows += BasePeer::doDelete($criteria, $con);
1323: GroupModulePeer::clearRelatedInstancePool();
1324: $con->commit();
1325:
1326: return $affectedRows;
1327: } catch (PropelException $e) {
1328: $con->rollBack();
1329: throw $e;
1330: }
1331: }
1332:
1333: /**
1334: * Validates all modified columns of given GroupModule object.
1335: * If parameter $columns is either a single column name or an array of column names
1336: * than only those columns are validated.
1337: *
1338: * NOTICE: This does not apply to primary or foreign keys for now.
1339: *
1340: * @param GroupModule $obj The object to validate.
1341: * @param mixed $cols Column name or array of column names.
1342: *
1343: * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
1344: */
1345: public static function doValidate($obj, $cols = null)
1346: {
1347: $columns = array();
1348:
1349: if ($cols) {
1350: $dbMap = Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME);
1351: $tableMap = $dbMap->getTable(GroupModulePeer::TABLE_NAME);
1352:
1353: if (! is_array($cols)) {
1354: $cols = array($cols);
1355: }
1356:
1357: foreach ($cols as $colName) {
1358: if ($tableMap->hasColumn($colName)) {
1359: $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
1360: $columns[$colName] = $obj->$get();
1361: }
1362: }
1363: } else {
1364:
1365: }
1366:
1367: return BasePeer::doValidate(GroupModulePeer::DATABASE_NAME, GroupModulePeer::TABLE_NAME, $columns);
1368: }
1369:
1370: /**
1371: * Retrieve a single object by pkey.
1372: *
1373: * @param int $pk the primary key.
1374: * @param PropelPDO $con the connection to use
1375: * @return GroupModule
1376: */
1377: public static function retrieveByPK($pk, PropelPDO $con = null)
1378: {
1379:
1380: if (null !== ($obj = GroupModulePeer::getInstanceFromPool((string) $pk))) {
1381: return $obj;
1382: }
1383:
1384: if ($con === null) {
1385: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
1386: }
1387:
1388: $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
1389: $criteria->add(GroupModulePeer::ID, $pk);
1390:
1391: $v = GroupModulePeer::doSelect($criteria, $con);
1392:
1393: return !empty($v) > 0 ? $v[0] : null;
1394: }
1395:
1396: /**
1397: * Retrieve multiple objects by pkey.
1398: *
1399: * @param array $pks List of primary keys
1400: * @param PropelPDO $con the connection to use
1401: * @return GroupModule[]
1402: * @throws PropelException Any exceptions caught during processing will be
1403: * rethrown wrapped into a PropelException.
1404: */
1405: public static function retrieveByPKs($pks, PropelPDO $con = null)
1406: {
1407: if ($con === null) {
1408: $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
1409: }
1410:
1411: $objs = null;
1412: if (empty($pks)) {
1413: $objs = array();
1414: } else {
1415: $criteria = new Criteria(GroupModulePeer::DATABASE_NAME);
1416: $criteria->add(GroupModulePeer::ID, $pks, Criteria::IN);
1417: $objs = GroupModulePeer::doSelect($criteria, $con);
1418: }
1419:
1420: return $objs;
1421: }
1422:
1423: } // BaseGroupModulePeer
1424:
1425: // This is the static code needed to register the TableMap for this table with the main Propel class.
1426: //
1427: BaseGroupModulePeer::buildTableMap();
1428:
1429: