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