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