Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

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