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