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