1: <?php
2:
3: namespace cli_db\propel\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \Exception;
9: use \PDO;
10: use \Persistent;
11: use \Propel;
12: use \PropelCollection;
13: use \PropelException;
14: use \PropelObjectCollection;
15: use \PropelPDO;
16: use cli_db\propel\Db;
17: use cli_db\propel\DbQuery;
18: use cli_db\propel\Dbxref;
19: use cli_db\propel\DbxrefPeer;
20: use cli_db\propel\DbxrefQuery;
21: use cli_db\propel\Feature;
22: use cli_db\propel\FeatureCvtermDbxref;
23: use cli_db\propel\FeatureCvtermDbxrefQuery;
24: use cli_db\propel\FeatureDbxref;
25: use cli_db\propel\FeatureDbxrefQuery;
26: use cli_db\propel\FeatureQuery;
27: use cli_db\propel\PubDbxref;
28: use cli_db\propel\PubDbxrefQuery;
29:
30: /**
31: * Base class that represents a row from the 'dbxref' table.
32: *
33: *
34: *
35: * @package propel.generator.cli_db.om
36: */
37: abstract class BaseDbxref extends BaseObject implements Persistent
38: {
39: /**
40: * Peer class name
41: */
42: const PEER = 'cli_db\\propel\\DbxrefPeer';
43:
44: /**
45: * The Peer class.
46: * Instance provides a convenient way of calling static methods on a class
47: * that calling code may not be able to identify.
48: * @var DbxrefPeer
49: */
50: protected static $peer;
51:
52: /**
53: * The flag var to prevent infinit loop in deep copy
54: * @var boolean
55: */
56: protected $startCopy = false;
57:
58: /**
59: * The value for the dbxref_id field.
60: * @var int
61: */
62: protected $dbxref_id;
63:
64: /**
65: * The value for the db_id field.
66: * @var int
67: */
68: protected $db_id;
69:
70: /**
71: * The value for the accession field.
72: * @var string
73: */
74: protected $accession;
75:
76: /**
77: * The value for the version field.
78: * Note: this column has a database default value of: ''
79: * @var string
80: */
81: protected $version;
82:
83: /**
84: * The value for the description field.
85: * @var string
86: */
87: protected $description;
88:
89: /**
90: * @var Db
91: */
92: protected $aDb;
93:
94: /**
95: * @var PropelObjectCollection|Feature[] Collection to store aggregation of Feature objects.
96: */
97: protected $collFeatures;
98: protected $collFeaturesPartial;
99:
100: /**
101: * @var PropelObjectCollection|FeatureCvtermDbxref[] Collection to store aggregation of FeatureCvtermDbxref objects.
102: */
103: protected $collFeatureCvtermDbxrefs;
104: protected $collFeatureCvtermDbxrefsPartial;
105:
106: /**
107: * @var PropelObjectCollection|FeatureDbxref[] Collection to store aggregation of FeatureDbxref objects.
108: */
109: protected $collFeatureDbxrefs;
110: protected $collFeatureDbxrefsPartial;
111:
112: /**
113: * @var PropelObjectCollection|PubDbxref[] Collection to store aggregation of PubDbxref objects.
114: */
115: protected $collPubDbxrefs;
116: protected $collPubDbxrefsPartial;
117:
118: /**
119: * Flag to prevent endless save loop, if this object is referenced
120: * by another object which falls in this transaction.
121: * @var boolean
122: */
123: protected $alreadyInSave = false;
124:
125: /**
126: * Flag to prevent endless validation loop, if this object is referenced
127: * by another object which falls in this transaction.
128: * @var boolean
129: */
130: protected $alreadyInValidation = false;
131:
132: /**
133: * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
134: * @var boolean
135: */
136: protected $alreadyInClearAllReferencesDeep = false;
137:
138: /**
139: * An array of objects scheduled for deletion.
140: * @var PropelObjectCollection
141: */
142: protected $featuresScheduledForDeletion = null;
143:
144: /**
145: * An array of objects scheduled for deletion.
146: * @var PropelObjectCollection
147: */
148: protected $featureCvtermDbxrefsScheduledForDeletion = null;
149:
150: /**
151: * An array of objects scheduled for deletion.
152: * @var PropelObjectCollection
153: */
154: protected $featureDbxrefsScheduledForDeletion = null;
155:
156: /**
157: * An array of objects scheduled for deletion.
158: * @var PropelObjectCollection
159: */
160: protected $pubDbxrefsScheduledForDeletion = null;
161:
162: /**
163: * Applies default values to this object.
164: * This method should be called from the object's constructor (or
165: * equivalent initialization method).
166: * @see __construct()
167: */
168: public function applyDefaultValues()
169: {
170: $this->version = '';
171: }
172:
173: /**
174: * Initializes internal state of BaseDbxref object.
175: * @see applyDefaults()
176: */
177: public function __construct()
178: {
179: parent::__construct();
180: $this->applyDefaultValues();
181: }
182:
183: /**
184: * Get the [dbxref_id] column value.
185: *
186: * @return int
187: */
188: public function getDbxrefId()
189: {
190: return $this->dbxref_id;
191: }
192:
193: /**
194: * Get the [db_id] column value.
195: *
196: * @return int
197: */
198: public function getDbId()
199: {
200: return $this->db_id;
201: }
202:
203: /**
204: * Get the [accession] column value.
205: *
206: * @return string
207: */
208: public function getAccession()
209: {
210: return $this->accession;
211: }
212:
213: /**
214: * Get the [version] column value.
215: *
216: * @return string
217: */
218: public function getVersion()
219: {
220: return $this->version;
221: }
222:
223: /**
224: * Get the [description] column value.
225: *
226: * @return string
227: */
228: public function getDescription()
229: {
230: return $this->description;
231: }
232:
233: /**
234: * Set the value of [dbxref_id] column.
235: *
236: * @param int $v new value
237: * @return Dbxref The current object (for fluent API support)
238: */
239: public function setDbxrefId($v)
240: {
241: if ($v !== null && is_numeric($v)) {
242: $v = (int) $v;
243: }
244:
245: if ($this->dbxref_id !== $v) {
246: $this->dbxref_id = $v;
247: $this->modifiedColumns[] = DbxrefPeer::DBXREF_ID;
248: }
249:
250:
251: return $this;
252: } // setDbxrefId()
253:
254: /**
255: * Set the value of [db_id] column.
256: *
257: * @param int $v new value
258: * @return Dbxref The current object (for fluent API support)
259: */
260: public function setDbId($v)
261: {
262: if ($v !== null && is_numeric($v)) {
263: $v = (int) $v;
264: }
265:
266: if ($this->db_id !== $v) {
267: $this->db_id = $v;
268: $this->modifiedColumns[] = DbxrefPeer::DB_ID;
269: }
270:
271: if ($this->aDb !== null && $this->aDb->getDbId() !== $v) {
272: $this->aDb = null;
273: }
274:
275:
276: return $this;
277: } // setDbId()
278:
279: /**
280: * Set the value of [accession] column.
281: *
282: * @param string $v new value
283: * @return Dbxref The current object (for fluent API support)
284: */
285: public function setAccession($v)
286: {
287: if ($v !== null && is_numeric($v)) {
288: $v = (string) $v;
289: }
290:
291: if ($this->accession !== $v) {
292: $this->accession = $v;
293: $this->modifiedColumns[] = DbxrefPeer::ACCESSION;
294: }
295:
296:
297: return $this;
298: } // setAccession()
299:
300: /**
301: * Set the value of [version] column.
302: *
303: * @param string $v new value
304: * @return Dbxref The current object (for fluent API support)
305: */
306: public function setVersion($v)
307: {
308: if ($v !== null && is_numeric($v)) {
309: $v = (string) $v;
310: }
311:
312: if ($this->version !== $v) {
313: $this->version = $v;
314: $this->modifiedColumns[] = DbxrefPeer::VERSION;
315: }
316:
317:
318: return $this;
319: } // setVersion()
320:
321: /**
322: * Set the value of [description] column.
323: *
324: * @param string $v new value
325: * @return Dbxref The current object (for fluent API support)
326: */
327: public function setDescription($v)
328: {
329: if ($v !== null && is_numeric($v)) {
330: $v = (string) $v;
331: }
332:
333: if ($this->description !== $v) {
334: $this->description = $v;
335: $this->modifiedColumns[] = DbxrefPeer::DESCRIPTION;
336: }
337:
338:
339: return $this;
340: } // setDescription()
341:
342: /**
343: * Indicates whether the columns in this object are only set to default values.
344: *
345: * This method can be used in conjunction with isModified() to indicate whether an object is both
346: * modified _and_ has some values set which are non-default.
347: *
348: * @return boolean Whether the columns in this object are only been set with default values.
349: */
350: public function hasOnlyDefaultValues()
351: {
352: if ($this->version !== '') {
353: return false;
354: }
355:
356: // otherwise, everything was equal, so return true
357: return true;
358: } // hasOnlyDefaultValues()
359:
360: /**
361: * Hydrates (populates) the object variables with values from the database resultset.
362: *
363: * An offset (0-based "start column") is specified so that objects can be hydrated
364: * with a subset of the columns in the resultset rows. This is needed, for example,
365: * for results of JOIN queries where the resultset row includes columns from two or
366: * more tables.
367: *
368: * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
369: * @param int $startcol 0-based offset column which indicates which restultset column to start with.
370: * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
371: * @return int next starting column
372: * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
373: */
374: public function hydrate($row, $startcol = 0, $rehydrate = false)
375: {
376: try {
377:
378: $this->dbxref_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
379: $this->db_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
380: $this->accession = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
381: $this->version = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
382: $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
383: $this->resetModified();
384:
385: $this->setNew(false);
386:
387: if ($rehydrate) {
388: $this->ensureConsistency();
389: }
390: $this->postHydrate($row, $startcol, $rehydrate);
391: return $startcol + 5; // 5 = DbxrefPeer::NUM_HYDRATE_COLUMNS.
392:
393: } catch (Exception $e) {
394: throw new PropelException("Error populating Dbxref object", $e);
395: }
396: }
397:
398: /**
399: * Checks and repairs the internal consistency of the object.
400: *
401: * This method is executed after an already-instantiated object is re-hydrated
402: * from the database. It exists to check any foreign keys to make sure that
403: * the objects related to the current object are correct based on foreign key.
404: *
405: * You can override this method in the stub class, but you should always invoke
406: * the base method from the overridden method (i.e. parent::ensureConsistency()),
407: * in case your model changes.
408: *
409: * @throws PropelException
410: */
411: public function ensureConsistency()
412: {
413:
414: if ($this->aDb !== null && $this->db_id !== $this->aDb->getDbId()) {
415: $this->aDb = null;
416: }
417: } // ensureConsistency
418:
419: /**
420: * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
421: *
422: * This will only work if the object has been saved and has a valid primary key set.
423: *
424: * @param boolean $deep (optional) Whether to also de-associated any related objects.
425: * @param PropelPDO $con (optional) The PropelPDO connection to use.
426: * @return void
427: * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
428: */
429: public function reload($deep = false, PropelPDO $con = null)
430: {
431: if ($this->isDeleted()) {
432: throw new PropelException("Cannot reload a deleted object.");
433: }
434:
435: if ($this->isNew()) {
436: throw new PropelException("Cannot reload an unsaved object.");
437: }
438:
439: if ($con === null) {
440: $con = Propel::getConnection(DbxrefPeer::DATABASE_NAME, Propel::CONNECTION_READ);
441: }
442:
443: // We don't need to alter the object instance pool; we're just modifying this instance
444: // already in the pool.
445:
446: $stmt = DbxrefPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
447: $row = $stmt->fetch(PDO::FETCH_NUM);
448: $stmt->closeCursor();
449: if (!$row) {
450: throw new PropelException('Cannot find matching row in the database to reload object values.');
451: }
452: $this->hydrate($row, 0, true); // rehydrate
453:
454: if ($deep) { // also de-associate any related objects?
455:
456: $this->aDb = null;
457: $this->collFeatures = null;
458:
459: $this->collFeatureCvtermDbxrefs = null;
460:
461: $this->collFeatureDbxrefs = null;
462:
463: $this->collPubDbxrefs = null;
464:
465: } // if (deep)
466: }
467:
468: /**
469: * Removes this object from datastore and sets delete attribute.
470: *
471: * @param PropelPDO $con
472: * @return void
473: * @throws PropelException
474: * @throws Exception
475: * @see BaseObject::setDeleted()
476: * @see BaseObject::isDeleted()
477: */
478: public function delete(PropelPDO $con = null)
479: {
480: if ($this->isDeleted()) {
481: throw new PropelException("This object has already been deleted.");
482: }
483:
484: if ($con === null) {
485: $con = Propel::getConnection(DbxrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
486: }
487:
488: $con->beginTransaction();
489: try {
490: $deleteQuery = DbxrefQuery::create()
491: ->filterByPrimaryKey($this->getPrimaryKey());
492: $ret = $this->preDelete($con);
493: if ($ret) {
494: $deleteQuery->delete($con);
495: $this->postDelete($con);
496: $con->commit();
497: $this->setDeleted(true);
498: } else {
499: $con->commit();
500: }
501: } catch (Exception $e) {
502: $con->rollBack();
503: throw $e;
504: }
505: }
506:
507: /**
508: * Persists this object to the database.
509: *
510: * If the object is new, it inserts it; otherwise an update is performed.
511: * All modified related objects will also be persisted in the doSave()
512: * method. This method wraps all precipitate database operations in a
513: * single transaction.
514: *
515: * @param PropelPDO $con
516: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
517: * @throws PropelException
518: * @throws Exception
519: * @see doSave()
520: */
521: public function save(PropelPDO $con = null)
522: {
523: if ($this->isDeleted()) {
524: throw new PropelException("You cannot save an object that has been deleted.");
525: }
526:
527: if ($con === null) {
528: $con = Propel::getConnection(DbxrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
529: }
530:
531: $con->beginTransaction();
532: $isInsert = $this->isNew();
533: try {
534: $ret = $this->preSave($con);
535: if ($isInsert) {
536: $ret = $ret && $this->preInsert($con);
537: } else {
538: $ret = $ret && $this->preUpdate($con);
539: }
540: if ($ret) {
541: $affectedRows = $this->doSave($con);
542: if ($isInsert) {
543: $this->postInsert($con);
544: } else {
545: $this->postUpdate($con);
546: }
547: $this->postSave($con);
548: DbxrefPeer::addInstanceToPool($this);
549: } else {
550: $affectedRows = 0;
551: }
552: $con->commit();
553:
554: return $affectedRows;
555: } catch (Exception $e) {
556: $con->rollBack();
557: throw $e;
558: }
559: }
560:
561: /**
562: * Performs the work of inserting or updating the row in the database.
563: *
564: * If the object is new, it inserts it; otherwise an update is performed.
565: * All related objects are also updated in this method.
566: *
567: * @param PropelPDO $con
568: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
569: * @throws PropelException
570: * @see save()
571: */
572: protected function doSave(PropelPDO $con)
573: {
574: $affectedRows = 0; // initialize var to track total num of affected rows
575: if (!$this->alreadyInSave) {
576: $this->alreadyInSave = true;
577:
578: // We call the save method on the following object(s) if they
579: // were passed to this object by their coresponding set
580: // method. This object relates to these object(s) by a
581: // foreign key reference.
582:
583: if ($this->aDb !== null) {
584: if ($this->aDb->isModified() || $this->aDb->isNew()) {
585: $affectedRows += $this->aDb->save($con);
586: }
587: $this->setDb($this->aDb);
588: }
589:
590: if ($this->isNew() || $this->isModified()) {
591: // persist changes
592: if ($this->isNew()) {
593: $this->doInsert($con);
594: } else {
595: $this->doUpdate($con);
596: }
597: $affectedRows += 1;
598: $this->resetModified();
599: }
600:
601: if ($this->featuresScheduledForDeletion !== null) {
602: if (!$this->featuresScheduledForDeletion->isEmpty()) {
603: foreach ($this->featuresScheduledForDeletion as $feature) {
604: // need to save related object because we set the relation to null
605: $feature->save($con);
606: }
607: $this->featuresScheduledForDeletion = null;
608: }
609: }
610:
611: if ($this->collFeatures !== null) {
612: foreach ($this->collFeatures as $referrerFK) {
613: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
614: $affectedRows += $referrerFK->save($con);
615: }
616: }
617: }
618:
619: if ($this->featureCvtermDbxrefsScheduledForDeletion !== null) {
620: if (!$this->featureCvtermDbxrefsScheduledForDeletion->isEmpty()) {
621: FeatureCvtermDbxrefQuery::create()
622: ->filterByPrimaryKeys($this->featureCvtermDbxrefsScheduledForDeletion->getPrimaryKeys(false))
623: ->delete($con);
624: $this->featureCvtermDbxrefsScheduledForDeletion = null;
625: }
626: }
627:
628: if ($this->collFeatureCvtermDbxrefs !== null) {
629: foreach ($this->collFeatureCvtermDbxrefs as $referrerFK) {
630: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
631: $affectedRows += $referrerFK->save($con);
632: }
633: }
634: }
635:
636: if ($this->featureDbxrefsScheduledForDeletion !== null) {
637: if (!$this->featureDbxrefsScheduledForDeletion->isEmpty()) {
638: FeatureDbxrefQuery::create()
639: ->filterByPrimaryKeys($this->featureDbxrefsScheduledForDeletion->getPrimaryKeys(false))
640: ->delete($con);
641: $this->featureDbxrefsScheduledForDeletion = null;
642: }
643: }
644:
645: if ($this->collFeatureDbxrefs !== null) {
646: foreach ($this->collFeatureDbxrefs as $referrerFK) {
647: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
648: $affectedRows += $referrerFK->save($con);
649: }
650: }
651: }
652:
653: if ($this->pubDbxrefsScheduledForDeletion !== null) {
654: if (!$this->pubDbxrefsScheduledForDeletion->isEmpty()) {
655: PubDbxrefQuery::create()
656: ->filterByPrimaryKeys($this->pubDbxrefsScheduledForDeletion->getPrimaryKeys(false))
657: ->delete($con);
658: $this->pubDbxrefsScheduledForDeletion = null;
659: }
660: }
661:
662: if ($this->collPubDbxrefs !== null) {
663: foreach ($this->collPubDbxrefs as $referrerFK) {
664: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
665: $affectedRows += $referrerFK->save($con);
666: }
667: }
668: }
669:
670: $this->alreadyInSave = false;
671:
672: }
673:
674: return $affectedRows;
675: } // doSave()
676:
677: /**
678: * Insert the row in the database.
679: *
680: * @param PropelPDO $con
681: *
682: * @throws PropelException
683: * @see doSave()
684: */
685: protected function doInsert(PropelPDO $con)
686: {
687: $modifiedColumns = array();
688: $index = 0;
689:
690: $this->modifiedColumns[] = DbxrefPeer::DBXREF_ID;
691: if (null !== $this->dbxref_id) {
692: throw new PropelException('Cannot insert a value for auto-increment primary key (' . DbxrefPeer::DBXREF_ID . ')');
693: }
694: if (null === $this->dbxref_id) {
695: try {
696: $stmt = $con->query("SELECT nextval('dbxref_dbxref_id_seq')");
697: $row = $stmt->fetch(PDO::FETCH_NUM);
698: $this->dbxref_id = $row[0];
699: } catch (Exception $e) {
700: throw new PropelException('Unable to get sequence id.', $e);
701: }
702: }
703:
704:
705: // check the columns in natural order for more readable SQL queries
706: if ($this->isColumnModified(DbxrefPeer::DBXREF_ID)) {
707: $modifiedColumns[':p' . $index++] = '"dbxref_id"';
708: }
709: if ($this->isColumnModified(DbxrefPeer::DB_ID)) {
710: $modifiedColumns[':p' . $index++] = '"db_id"';
711: }
712: if ($this->isColumnModified(DbxrefPeer::ACCESSION)) {
713: $modifiedColumns[':p' . $index++] = '"accession"';
714: }
715: if ($this->isColumnModified(DbxrefPeer::VERSION)) {
716: $modifiedColumns[':p' . $index++] = '"version"';
717: }
718: if ($this->isColumnModified(DbxrefPeer::DESCRIPTION)) {
719: $modifiedColumns[':p' . $index++] = '"description"';
720: }
721:
722: $sql = sprintf(
723: 'INSERT INTO "dbxref" (%s) VALUES (%s)',
724: implode(', ', $modifiedColumns),
725: implode(', ', array_keys($modifiedColumns))
726: );
727:
728: try {
729: $stmt = $con->prepare($sql);
730: foreach ($modifiedColumns as $identifier => $columnName) {
731: switch ($columnName) {
732: case '"dbxref_id"':
733: $stmt->bindValue($identifier, $this->dbxref_id, PDO::PARAM_INT);
734: break;
735: case '"db_id"':
736: $stmt->bindValue($identifier, $this->db_id, PDO::PARAM_INT);
737: break;
738: case '"accession"':
739: $stmt->bindValue($identifier, $this->accession, PDO::PARAM_STR);
740: break;
741: case '"version"':
742: $stmt->bindValue($identifier, $this->version, PDO::PARAM_STR);
743: break;
744: case '"description"':
745: $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
746: break;
747: }
748: }
749: $stmt->execute();
750: } catch (Exception $e) {
751: Propel::log($e->getMessage(), Propel::LOG_ERR);
752: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
753: }
754:
755: $this->setNew(false);
756: }
757:
758: /**
759: * Update the row in the database.
760: *
761: * @param PropelPDO $con
762: *
763: * @see doSave()
764: */
765: protected function doUpdate(PropelPDO $con)
766: {
767: $selectCriteria = $this->buildPkeyCriteria();
768: $valuesCriteria = $this->buildCriteria();
769: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
770: }
771:
772: /**
773: * Array of ValidationFailed objects.
774: * @var array ValidationFailed[]
775: */
776: protected $validationFailures = array();
777:
778: /**
779: * Gets any ValidationFailed objects that resulted from last call to validate().
780: *
781: *
782: * @return array ValidationFailed[]
783: * @see validate()
784: */
785: public function getValidationFailures()
786: {
787: return $this->validationFailures;
788: }
789:
790: /**
791: * Validates the objects modified field values and all objects related to this table.
792: *
793: * If $columns is either a column name or an array of column names
794: * only those columns are validated.
795: *
796: * @param mixed $columns Column name or an array of column names.
797: * @return boolean Whether all columns pass validation.
798: * @see doValidate()
799: * @see getValidationFailures()
800: */
801: public function validate($columns = null)
802: {
803: $res = $this->doValidate($columns);
804: if ($res === true) {
805: $this->validationFailures = array();
806:
807: return true;
808: }
809:
810: $this->validationFailures = $res;
811:
812: return false;
813: }
814:
815: /**
816: * This function performs the validation work for complex object models.
817: *
818: * In addition to checking the current object, all related objects will
819: * also be validated. If all pass then <code>true</code> is returned; otherwise
820: * an aggreagated array of ValidationFailed objects will be returned.
821: *
822: * @param array $columns Array of column names to validate.
823: * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
824: */
825: protected function doValidate($columns = null)
826: {
827: if (!$this->alreadyInValidation) {
828: $this->alreadyInValidation = true;
829: $retval = null;
830:
831: $failureMap = array();
832:
833:
834: // We call the validate method on the following object(s) if they
835: // were passed to this object by their coresponding set
836: // method. This object relates to these object(s) by a
837: // foreign key reference.
838:
839: if ($this->aDb !== null) {
840: if (!$this->aDb->validate($columns)) {
841: $failureMap = array_merge($failureMap, $this->aDb->getValidationFailures());
842: }
843: }
844:
845:
846: if (($retval = DbxrefPeer::doValidate($this, $columns)) !== true) {
847: $failureMap = array_merge($failureMap, $retval);
848: }
849:
850:
851: if ($this->collFeatures !== null) {
852: foreach ($this->collFeatures as $referrerFK) {
853: if (!$referrerFK->validate($columns)) {
854: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
855: }
856: }
857: }
858:
859: if ($this->collFeatureCvtermDbxrefs !== null) {
860: foreach ($this->collFeatureCvtermDbxrefs as $referrerFK) {
861: if (!$referrerFK->validate($columns)) {
862: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
863: }
864: }
865: }
866:
867: if ($this->collFeatureDbxrefs !== null) {
868: foreach ($this->collFeatureDbxrefs as $referrerFK) {
869: if (!$referrerFK->validate($columns)) {
870: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
871: }
872: }
873: }
874:
875: if ($this->collPubDbxrefs !== null) {
876: foreach ($this->collPubDbxrefs as $referrerFK) {
877: if (!$referrerFK->validate($columns)) {
878: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
879: }
880: }
881: }
882:
883:
884: $this->alreadyInValidation = false;
885: }
886:
887: return (!empty($failureMap) ? $failureMap : true);
888: }
889:
890: /**
891: * Retrieves a field from the object by name passed in as a string.
892: *
893: * @param string $name name
894: * @param string $type The type of fieldname the $name is of:
895: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
896: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
897: * Defaults to BasePeer::TYPE_PHPNAME
898: * @return mixed Value of field.
899: */
900: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
901: {
902: $pos = DbxrefPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
903: $field = $this->getByPosition($pos);
904:
905: return $field;
906: }
907:
908: /**
909: * Retrieves a field from the object by Position as specified in the xml schema.
910: * Zero-based.
911: *
912: * @param int $pos position in xml schema
913: * @return mixed Value of field at $pos
914: */
915: public function getByPosition($pos)
916: {
917: switch ($pos) {
918: case 0:
919: return $this->getDbxrefId();
920: break;
921: case 1:
922: return $this->getDbId();
923: break;
924: case 2:
925: return $this->getAccession();
926: break;
927: case 3:
928: return $this->getVersion();
929: break;
930: case 4:
931: return $this->getDescription();
932: break;
933: default:
934: return null;
935: break;
936: } // switch()
937: }
938:
939: /**
940: * Exports the object as an array.
941: *
942: * You can specify the key type of the array by passing one of the class
943: * type constants.
944: *
945: * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
946: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
947: * Defaults to BasePeer::TYPE_PHPNAME.
948: * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
949: * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
950: * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
951: *
952: * @return array an associative array containing the field names (as keys) and field values
953: */
954: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
955: {
956: if (isset($alreadyDumpedObjects['Dbxref'][$this->getPrimaryKey()])) {
957: return '*RECURSION*';
958: }
959: $alreadyDumpedObjects['Dbxref'][$this->getPrimaryKey()] = true;
960: $keys = DbxrefPeer::getFieldNames($keyType);
961: $result = array(
962: $keys[0] => $this->getDbxrefId(),
963: $keys[1] => $this->getDbId(),
964: $keys[2] => $this->getAccession(),
965: $keys[3] => $this->getVersion(),
966: $keys[4] => $this->getDescription(),
967: );
968: if ($includeForeignObjects) {
969: if (null !== $this->aDb) {
970: $result['Db'] = $this->aDb->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
971: }
972: if (null !== $this->collFeatures) {
973: $result['Features'] = $this->collFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
974: }
975: if (null !== $this->collFeatureCvtermDbxrefs) {
976: $result['FeatureCvtermDbxrefs'] = $this->collFeatureCvtermDbxrefs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
977: }
978: if (null !== $this->collFeatureDbxrefs) {
979: $result['FeatureDbxrefs'] = $this->collFeatureDbxrefs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
980: }
981: if (null !== $this->collPubDbxrefs) {
982: $result['PubDbxrefs'] = $this->collPubDbxrefs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
983: }
984: }
985:
986: return $result;
987: }
988:
989: /**
990: * Sets a field from the object by name passed in as a string.
991: *
992: * @param string $name peer name
993: * @param mixed $value field value
994: * @param string $type The type of fieldname the $name is of:
995: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
996: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
997: * Defaults to BasePeer::TYPE_PHPNAME
998: * @return void
999: */
1000: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1001: {
1002: $pos = DbxrefPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1003:
1004: $this->setByPosition($pos, $value);
1005: }
1006:
1007: /**
1008: * Sets a field from the object by Position as specified in the xml schema.
1009: * Zero-based.
1010: *
1011: * @param int $pos position in xml schema
1012: * @param mixed $value field value
1013: * @return void
1014: */
1015: public function setByPosition($pos, $value)
1016: {
1017: switch ($pos) {
1018: case 0:
1019: $this->setDbxrefId($value);
1020: break;
1021: case 1:
1022: $this->setDbId($value);
1023: break;
1024: case 2:
1025: $this->setAccession($value);
1026: break;
1027: case 3:
1028: $this->setVersion($value);
1029: break;
1030: case 4:
1031: $this->setDescription($value);
1032: break;
1033: } // switch()
1034: }
1035:
1036: /**
1037: * Populates the object using an array.
1038: *
1039: * This is particularly useful when populating an object from one of the
1040: * request arrays (e.g. $_POST). This method goes through the column
1041: * names, checking to see whether a matching key exists in populated
1042: * array. If so the setByName() method is called for that column.
1043: *
1044: * You can specify the key type of the array by additionally passing one
1045: * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1046: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1047: * The default key type is the column's BasePeer::TYPE_PHPNAME
1048: *
1049: * @param array $arr An array to populate the object from.
1050: * @param string $keyType The type of keys the array uses.
1051: * @return void
1052: */
1053: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1054: {
1055: $keys = DbxrefPeer::getFieldNames($keyType);
1056:
1057: if (array_key_exists($keys[0], $arr)) $this->setDbxrefId($arr[$keys[0]]);
1058: if (array_key_exists($keys[1], $arr)) $this->setDbId($arr[$keys[1]]);
1059: if (array_key_exists($keys[2], $arr)) $this->setAccession($arr[$keys[2]]);
1060: if (array_key_exists($keys[3], $arr)) $this->setVersion($arr[$keys[3]]);
1061: if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
1062: }
1063:
1064: /**
1065: * Build a Criteria object containing the values of all modified columns in this object.
1066: *
1067: * @return Criteria The Criteria object containing all modified values.
1068: */
1069: public function buildCriteria()
1070: {
1071: $criteria = new Criteria(DbxrefPeer::DATABASE_NAME);
1072:
1073: if ($this->isColumnModified(DbxrefPeer::DBXREF_ID)) $criteria->add(DbxrefPeer::DBXREF_ID, $this->dbxref_id);
1074: if ($this->isColumnModified(DbxrefPeer::DB_ID)) $criteria->add(DbxrefPeer::DB_ID, $this->db_id);
1075: if ($this->isColumnModified(DbxrefPeer::ACCESSION)) $criteria->add(DbxrefPeer::ACCESSION, $this->accession);
1076: if ($this->isColumnModified(DbxrefPeer::VERSION)) $criteria->add(DbxrefPeer::VERSION, $this->version);
1077: if ($this->isColumnModified(DbxrefPeer::DESCRIPTION)) $criteria->add(DbxrefPeer::DESCRIPTION, $this->description);
1078:
1079: return $criteria;
1080: }
1081:
1082: /**
1083: * Builds a Criteria object containing the primary key for this object.
1084: *
1085: * Unlike buildCriteria() this method includes the primary key values regardless
1086: * of whether or not they have been modified.
1087: *
1088: * @return Criteria The Criteria object containing value(s) for primary key(s).
1089: */
1090: public function buildPkeyCriteria()
1091: {
1092: $criteria = new Criteria(DbxrefPeer::DATABASE_NAME);
1093: $criteria->add(DbxrefPeer::DBXREF_ID, $this->dbxref_id);
1094:
1095: return $criteria;
1096: }
1097:
1098: /**
1099: * Returns the primary key for this object (row).
1100: * @return int
1101: */
1102: public function getPrimaryKey()
1103: {
1104: return $this->getDbxrefId();
1105: }
1106:
1107: /**
1108: * Generic method to set the primary key (dbxref_id column).
1109: *
1110: * @param int $key Primary key.
1111: * @return void
1112: */
1113: public function setPrimaryKey($key)
1114: {
1115: $this->setDbxrefId($key);
1116: }
1117:
1118: /**
1119: * Returns true if the primary key for this object is null.
1120: * @return boolean
1121: */
1122: public function isPrimaryKeyNull()
1123: {
1124:
1125: return null === $this->getDbxrefId();
1126: }
1127:
1128: /**
1129: * Sets contents of passed object to values from current object.
1130: *
1131: * If desired, this method can also make copies of all associated (fkey referrers)
1132: * objects.
1133: *
1134: * @param object $copyObj An object of Dbxref (or compatible) type.
1135: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1136: * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1137: * @throws PropelException
1138: */
1139: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1140: {
1141: $copyObj->setDbId($this->getDbId());
1142: $copyObj->setAccession($this->getAccession());
1143: $copyObj->setVersion($this->getVersion());
1144: $copyObj->setDescription($this->getDescription());
1145:
1146: if ($deepCopy && !$this->startCopy) {
1147: // important: temporarily setNew(false) because this affects the behavior of
1148: // the getter/setter methods for fkey referrer objects.
1149: $copyObj->setNew(false);
1150: // store object hash to prevent cycle
1151: $this->startCopy = true;
1152:
1153: foreach ($this->getFeatures() as $relObj) {
1154: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1155: $copyObj->addFeature($relObj->copy($deepCopy));
1156: }
1157: }
1158:
1159: foreach ($this->getFeatureCvtermDbxrefs() as $relObj) {
1160: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1161: $copyObj->addFeatureCvtermDbxref($relObj->copy($deepCopy));
1162: }
1163: }
1164:
1165: foreach ($this->getFeatureDbxrefs() as $relObj) {
1166: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1167: $copyObj->addFeatureDbxref($relObj->copy($deepCopy));
1168: }
1169: }
1170:
1171: foreach ($this->getPubDbxrefs() as $relObj) {
1172: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1173: $copyObj->addPubDbxref($relObj->copy($deepCopy));
1174: }
1175: }
1176:
1177: //unflag object copy
1178: $this->startCopy = false;
1179: } // if ($deepCopy)
1180:
1181: if ($makeNew) {
1182: $copyObj->setNew(true);
1183: $copyObj->setDbxrefId(NULL); // this is a auto-increment column, so set to default value
1184: }
1185: }
1186:
1187: /**
1188: * Makes a copy of this object that will be inserted as a new row in table when saved.
1189: * It creates a new object filling in the simple attributes, but skipping any primary
1190: * keys that are defined for the table.
1191: *
1192: * If desired, this method can also make copies of all associated (fkey referrers)
1193: * objects.
1194: *
1195: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1196: * @return Dbxref Clone of current object.
1197: * @throws PropelException
1198: */
1199: public function copy($deepCopy = false)
1200: {
1201: // we use get_class(), because this might be a subclass
1202: $clazz = get_class($this);
1203: $copyObj = new $clazz();
1204: $this->copyInto($copyObj, $deepCopy);
1205:
1206: return $copyObj;
1207: }
1208:
1209: /**
1210: * Returns a peer instance associated with this om.
1211: *
1212: * Since Peer classes are not to have any instance attributes, this method returns the
1213: * same instance for all member of this class. The method could therefore
1214: * be static, but this would prevent one from overriding the behavior.
1215: *
1216: * @return DbxrefPeer
1217: */
1218: public function getPeer()
1219: {
1220: if (self::$peer === null) {
1221: self::$peer = new DbxrefPeer();
1222: }
1223:
1224: return self::$peer;
1225: }
1226:
1227: /**
1228: * Declares an association between this object and a Db object.
1229: *
1230: * @param Db $v
1231: * @return Dbxref The current object (for fluent API support)
1232: * @throws PropelException
1233: */
1234: public function setDb(Db $v = null)
1235: {
1236: if ($v === null) {
1237: $this->setDbId(NULL);
1238: } else {
1239: $this->setDbId($v->getDbId());
1240: }
1241:
1242: $this->aDb = $v;
1243:
1244: // Add binding for other direction of this n:n relationship.
1245: // If this object has already been added to the Db object, it will not be re-added.
1246: if ($v !== null) {
1247: $v->addDbxref($this);
1248: }
1249:
1250:
1251: return $this;
1252: }
1253:
1254:
1255: /**
1256: * Get the associated Db object
1257: *
1258: * @param PropelPDO $con Optional Connection object.
1259: * @param $doQuery Executes a query to get the object if required
1260: * @return Db The associated Db object.
1261: * @throws PropelException
1262: */
1263: public function getDb(PropelPDO $con = null, $doQuery = true)
1264: {
1265: if ($this->aDb === null && ($this->db_id !== null) && $doQuery) {
1266: $this->aDb = DbQuery::create()->findPk($this->db_id, $con);
1267: /* The following can be used additionally to
1268: guarantee the related object contains a reference
1269: to this object. This level of coupling may, however, be
1270: undesirable since it could result in an only partially populated collection
1271: in the referenced object.
1272: $this->aDb->addDbxrefs($this);
1273: */
1274: }
1275:
1276: return $this->aDb;
1277: }
1278:
1279:
1280: /**
1281: * Initializes a collection based on the name of a relation.
1282: * Avoids crafting an 'init[$relationName]s' method name
1283: * that wouldn't work when StandardEnglishPluralizer is used.
1284: *
1285: * @param string $relationName The name of the relation to initialize
1286: * @return void
1287: */
1288: public function initRelation($relationName)
1289: {
1290: if ('Feature' == $relationName) {
1291: $this->initFeatures();
1292: }
1293: if ('FeatureCvtermDbxref' == $relationName) {
1294: $this->initFeatureCvtermDbxrefs();
1295: }
1296: if ('FeatureDbxref' == $relationName) {
1297: $this->initFeatureDbxrefs();
1298: }
1299: if ('PubDbxref' == $relationName) {
1300: $this->initPubDbxrefs();
1301: }
1302: }
1303:
1304: /**
1305: * Clears out the collFeatures collection
1306: *
1307: * This does not modify the database; however, it will remove any associated objects, causing
1308: * them to be refetched by subsequent calls to accessor method.
1309: *
1310: * @return Dbxref The current object (for fluent API support)
1311: * @see addFeatures()
1312: */
1313: public function clearFeatures()
1314: {
1315: $this->collFeatures = null; // important to set this to null since that means it is uninitialized
1316: $this->collFeaturesPartial = null;
1317:
1318: return $this;
1319: }
1320:
1321: /**
1322: * reset is the collFeatures collection loaded partially
1323: *
1324: * @return void
1325: */
1326: public function resetPartialFeatures($v = true)
1327: {
1328: $this->collFeaturesPartial = $v;
1329: }
1330:
1331: /**
1332: * Initializes the collFeatures collection.
1333: *
1334: * By default this just sets the collFeatures collection to an empty array (like clearcollFeatures());
1335: * however, you may wish to override this method in your stub class to provide setting appropriate
1336: * to your application -- for example, setting the initial array to the values stored in database.
1337: *
1338: * @param boolean $overrideExisting If set to true, the method call initializes
1339: * the collection even if it is not empty
1340: *
1341: * @return void
1342: */
1343: public function initFeatures($overrideExisting = true)
1344: {
1345: if (null !== $this->collFeatures && !$overrideExisting) {
1346: return;
1347: }
1348: $this->collFeatures = new PropelObjectCollection();
1349: $this->collFeatures->setModel('Feature');
1350: }
1351:
1352: /**
1353: * Gets an array of Feature objects which contain a foreign key that references this object.
1354: *
1355: * If the $criteria is not null, it is used to always fetch the results from the database.
1356: * Otherwise the results are fetched from the database the first time, then cached.
1357: * Next time the same method is called without $criteria, the cached collection is returned.
1358: * If this Dbxref is new, it will return
1359: * an empty collection or the current collection; the criteria is ignored on a new object.
1360: *
1361: * @param Criteria $criteria optional Criteria object to narrow the query
1362: * @param PropelPDO $con optional connection object
1363: * @return PropelObjectCollection|Feature[] List of Feature objects
1364: * @throws PropelException
1365: */
1366: public function getFeatures($criteria = null, PropelPDO $con = null)
1367: {
1368: $partial = $this->collFeaturesPartial && !$this->isNew();
1369: if (null === $this->collFeatures || null !== $criteria || $partial) {
1370: if ($this->isNew() && null === $this->collFeatures) {
1371: // return empty collection
1372: $this->initFeatures();
1373: } else {
1374: $collFeatures = FeatureQuery::create(null, $criteria)
1375: ->filterByDbxref($this)
1376: ->find($con);
1377: if (null !== $criteria) {
1378: if (false !== $this->collFeaturesPartial && count($collFeatures)) {
1379: $this->initFeatures(false);
1380:
1381: foreach($collFeatures as $obj) {
1382: if (false == $this->collFeatures->contains($obj)) {
1383: $this->collFeatures->append($obj);
1384: }
1385: }
1386:
1387: $this->collFeaturesPartial = true;
1388: }
1389:
1390: $collFeatures->getInternalIterator()->rewind();
1391: return $collFeatures;
1392: }
1393:
1394: if($partial && $this->collFeatures) {
1395: foreach($this->collFeatures as $obj) {
1396: if($obj->isNew()) {
1397: $collFeatures[] = $obj;
1398: }
1399: }
1400: }
1401:
1402: $this->collFeatures = $collFeatures;
1403: $this->collFeaturesPartial = false;
1404: }
1405: }
1406:
1407: return $this->collFeatures;
1408: }
1409:
1410: /**
1411: * Sets a collection of Feature objects related by a one-to-many relationship
1412: * to the current object.
1413: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1414: * and new objects from the given Propel collection.
1415: *
1416: * @param PropelCollection $features A Propel collection.
1417: * @param PropelPDO $con Optional connection object
1418: * @return Dbxref The current object (for fluent API support)
1419: */
1420: public function setFeatures(PropelCollection $features, PropelPDO $con = null)
1421: {
1422: $featuresToDelete = $this->getFeatures(new Criteria(), $con)->diff($features);
1423:
1424: $this->featuresScheduledForDeletion = unserialize(serialize($featuresToDelete));
1425:
1426: foreach ($featuresToDelete as $featureRemoved) {
1427: $featureRemoved->setDbxref(null);
1428: }
1429:
1430: $this->collFeatures = null;
1431: foreach ($features as $feature) {
1432: $this->addFeature($feature);
1433: }
1434:
1435: $this->collFeatures = $features;
1436: $this->collFeaturesPartial = false;
1437:
1438: return $this;
1439: }
1440:
1441: /**
1442: * Returns the number of related Feature objects.
1443: *
1444: * @param Criteria $criteria
1445: * @param boolean $distinct
1446: * @param PropelPDO $con
1447: * @return int Count of related Feature objects.
1448: * @throws PropelException
1449: */
1450: public function countFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1451: {
1452: $partial = $this->collFeaturesPartial && !$this->isNew();
1453: if (null === $this->collFeatures || null !== $criteria || $partial) {
1454: if ($this->isNew() && null === $this->collFeatures) {
1455: return 0;
1456: }
1457:
1458: if($partial && !$criteria) {
1459: return count($this->getFeatures());
1460: }
1461: $query = FeatureQuery::create(null, $criteria);
1462: if ($distinct) {
1463: $query->distinct();
1464: }
1465:
1466: return $query
1467: ->filterByDbxref($this)
1468: ->count($con);
1469: }
1470:
1471: return count($this->collFeatures);
1472: }
1473:
1474: /**
1475: * Method called to associate a Feature object to this object
1476: * through the Feature foreign key attribute.
1477: *
1478: * @param Feature $l Feature
1479: * @return Dbxref The current object (for fluent API support)
1480: */
1481: public function addFeature(Feature $l)
1482: {
1483: if ($this->collFeatures === null) {
1484: $this->initFeatures();
1485: $this->collFeaturesPartial = true;
1486: }
1487: if (!in_array($l, $this->collFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1488: $this->doAddFeature($l);
1489: }
1490:
1491: return $this;
1492: }
1493:
1494: /**
1495: * @param Feature $feature The feature object to add.
1496: */
1497: protected function doAddFeature($feature)
1498: {
1499: $this->collFeatures[]= $feature;
1500: $feature->setDbxref($this);
1501: }
1502:
1503: /**
1504: * @param Feature $feature The feature object to remove.
1505: * @return Dbxref The current object (for fluent API support)
1506: */
1507: public function removeFeature($feature)
1508: {
1509: if ($this->getFeatures()->contains($feature)) {
1510: $this->collFeatures->remove($this->collFeatures->search($feature));
1511: if (null === $this->featuresScheduledForDeletion) {
1512: $this->featuresScheduledForDeletion = clone $this->collFeatures;
1513: $this->featuresScheduledForDeletion->clear();
1514: }
1515: $this->featuresScheduledForDeletion[]= $feature;
1516: $feature->setDbxref(null);
1517: }
1518:
1519: return $this;
1520: }
1521:
1522:
1523: /**
1524: * If this collection has already been initialized with
1525: * an identical criteria, it returns the collection.
1526: * Otherwise if this Dbxref is new, it will return
1527: * an empty collection; or if this Dbxref has previously
1528: * been saved, it will retrieve related Features from storage.
1529: *
1530: * This method is protected by default in order to keep the public
1531: * api reasonable. You can provide public methods for those you
1532: * actually need in Dbxref.
1533: *
1534: * @param Criteria $criteria optional Criteria object to narrow the query
1535: * @param PropelPDO $con optional connection object
1536: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1537: * @return PropelObjectCollection|Feature[] List of Feature objects
1538: */
1539: public function getFeaturesJoinOrganism($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1540: {
1541: $query = FeatureQuery::create(null, $criteria);
1542: $query->joinWith('Organism', $join_behavior);
1543:
1544: return $this->getFeatures($query, $con);
1545: }
1546:
1547:
1548: /**
1549: * If this collection has already been initialized with
1550: * an identical criteria, it returns the collection.
1551: * Otherwise if this Dbxref is new, it will return
1552: * an empty collection; or if this Dbxref has previously
1553: * been saved, it will retrieve related Features from storage.
1554: *
1555: * This method is protected by default in order to keep the public
1556: * api reasonable. You can provide public methods for those you
1557: * actually need in Dbxref.
1558: *
1559: * @param Criteria $criteria optional Criteria object to narrow the query
1560: * @param PropelPDO $con optional connection object
1561: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1562: * @return PropelObjectCollection|Feature[] List of Feature objects
1563: */
1564: public function getFeaturesJoinCvterm($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1565: {
1566: $query = FeatureQuery::create(null, $criteria);
1567: $query->joinWith('Cvterm', $join_behavior);
1568:
1569: return $this->getFeatures($query, $con);
1570: }
1571:
1572: /**
1573: * Clears out the collFeatureCvtermDbxrefs collection
1574: *
1575: * This does not modify the database; however, it will remove any associated objects, causing
1576: * them to be refetched by subsequent calls to accessor method.
1577: *
1578: * @return Dbxref The current object (for fluent API support)
1579: * @see addFeatureCvtermDbxrefs()
1580: */
1581: public function clearFeatureCvtermDbxrefs()
1582: {
1583: $this->collFeatureCvtermDbxrefs = null; // important to set this to null since that means it is uninitialized
1584: $this->collFeatureCvtermDbxrefsPartial = null;
1585:
1586: return $this;
1587: }
1588:
1589: /**
1590: * reset is the collFeatureCvtermDbxrefs collection loaded partially
1591: *
1592: * @return void
1593: */
1594: public function resetPartialFeatureCvtermDbxrefs($v = true)
1595: {
1596: $this->collFeatureCvtermDbxrefsPartial = $v;
1597: }
1598:
1599: /**
1600: * Initializes the collFeatureCvtermDbxrefs collection.
1601: *
1602: * By default this just sets the collFeatureCvtermDbxrefs collection to an empty array (like clearcollFeatureCvtermDbxrefs());
1603: * however, you may wish to override this method in your stub class to provide setting appropriate
1604: * to your application -- for example, setting the initial array to the values stored in database.
1605: *
1606: * @param boolean $overrideExisting If set to true, the method call initializes
1607: * the collection even if it is not empty
1608: *
1609: * @return void
1610: */
1611: public function initFeatureCvtermDbxrefs($overrideExisting = true)
1612: {
1613: if (null !== $this->collFeatureCvtermDbxrefs && !$overrideExisting) {
1614: return;
1615: }
1616: $this->collFeatureCvtermDbxrefs = new PropelObjectCollection();
1617: $this->collFeatureCvtermDbxrefs->setModel('FeatureCvtermDbxref');
1618: }
1619:
1620: /**
1621: * Gets an array of FeatureCvtermDbxref objects which contain a foreign key that references this object.
1622: *
1623: * If the $criteria is not null, it is used to always fetch the results from the database.
1624: * Otherwise the results are fetched from the database the first time, then cached.
1625: * Next time the same method is called without $criteria, the cached collection is returned.
1626: * If this Dbxref is new, it will return
1627: * an empty collection or the current collection; the criteria is ignored on a new object.
1628: *
1629: * @param Criteria $criteria optional Criteria object to narrow the query
1630: * @param PropelPDO $con optional connection object
1631: * @return PropelObjectCollection|FeatureCvtermDbxref[] List of FeatureCvtermDbxref objects
1632: * @throws PropelException
1633: */
1634: public function getFeatureCvtermDbxrefs($criteria = null, PropelPDO $con = null)
1635: {
1636: $partial = $this->collFeatureCvtermDbxrefsPartial && !$this->isNew();
1637: if (null === $this->collFeatureCvtermDbxrefs || null !== $criteria || $partial) {
1638: if ($this->isNew() && null === $this->collFeatureCvtermDbxrefs) {
1639: // return empty collection
1640: $this->initFeatureCvtermDbxrefs();
1641: } else {
1642: $collFeatureCvtermDbxrefs = FeatureCvtermDbxrefQuery::create(null, $criteria)
1643: ->filterByDbxref($this)
1644: ->find($con);
1645: if (null !== $criteria) {
1646: if (false !== $this->collFeatureCvtermDbxrefsPartial && count($collFeatureCvtermDbxrefs)) {
1647: $this->initFeatureCvtermDbxrefs(false);
1648:
1649: foreach($collFeatureCvtermDbxrefs as $obj) {
1650: if (false == $this->collFeatureCvtermDbxrefs->contains($obj)) {
1651: $this->collFeatureCvtermDbxrefs->append($obj);
1652: }
1653: }
1654:
1655: $this->collFeatureCvtermDbxrefsPartial = true;
1656: }
1657:
1658: $collFeatureCvtermDbxrefs->getInternalIterator()->rewind();
1659: return $collFeatureCvtermDbxrefs;
1660: }
1661:
1662: if($partial && $this->collFeatureCvtermDbxrefs) {
1663: foreach($this->collFeatureCvtermDbxrefs as $obj) {
1664: if($obj->isNew()) {
1665: $collFeatureCvtermDbxrefs[] = $obj;
1666: }
1667: }
1668: }
1669:
1670: $this->collFeatureCvtermDbxrefs = $collFeatureCvtermDbxrefs;
1671: $this->collFeatureCvtermDbxrefsPartial = false;
1672: }
1673: }
1674:
1675: return $this->collFeatureCvtermDbxrefs;
1676: }
1677:
1678: /**
1679: * Sets a collection of FeatureCvtermDbxref objects related by a one-to-many relationship
1680: * to the current object.
1681: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1682: * and new objects from the given Propel collection.
1683: *
1684: * @param PropelCollection $featureCvtermDbxrefs A Propel collection.
1685: * @param PropelPDO $con Optional connection object
1686: * @return Dbxref The current object (for fluent API support)
1687: */
1688: public function setFeatureCvtermDbxrefs(PropelCollection $featureCvtermDbxrefs, PropelPDO $con = null)
1689: {
1690: $featureCvtermDbxrefsToDelete = $this->getFeatureCvtermDbxrefs(new Criteria(), $con)->diff($featureCvtermDbxrefs);
1691:
1692: $this->featureCvtermDbxrefsScheduledForDeletion = unserialize(serialize($featureCvtermDbxrefsToDelete));
1693:
1694: foreach ($featureCvtermDbxrefsToDelete as $featureCvtermDbxrefRemoved) {
1695: $featureCvtermDbxrefRemoved->setDbxref(null);
1696: }
1697:
1698: $this->collFeatureCvtermDbxrefs = null;
1699: foreach ($featureCvtermDbxrefs as $featureCvtermDbxref) {
1700: $this->addFeatureCvtermDbxref($featureCvtermDbxref);
1701: }
1702:
1703: $this->collFeatureCvtermDbxrefs = $featureCvtermDbxrefs;
1704: $this->collFeatureCvtermDbxrefsPartial = false;
1705:
1706: return $this;
1707: }
1708:
1709: /**
1710: * Returns the number of related FeatureCvtermDbxref objects.
1711: *
1712: * @param Criteria $criteria
1713: * @param boolean $distinct
1714: * @param PropelPDO $con
1715: * @return int Count of related FeatureCvtermDbxref objects.
1716: * @throws PropelException
1717: */
1718: public function countFeatureCvtermDbxrefs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1719: {
1720: $partial = $this->collFeatureCvtermDbxrefsPartial && !$this->isNew();
1721: if (null === $this->collFeatureCvtermDbxrefs || null !== $criteria || $partial) {
1722: if ($this->isNew() && null === $this->collFeatureCvtermDbxrefs) {
1723: return 0;
1724: }
1725:
1726: if($partial && !$criteria) {
1727: return count($this->getFeatureCvtermDbxrefs());
1728: }
1729: $query = FeatureCvtermDbxrefQuery::create(null, $criteria);
1730: if ($distinct) {
1731: $query->distinct();
1732: }
1733:
1734: return $query
1735: ->filterByDbxref($this)
1736: ->count($con);
1737: }
1738:
1739: return count($this->collFeatureCvtermDbxrefs);
1740: }
1741:
1742: /**
1743: * Method called to associate a FeatureCvtermDbxref object to this object
1744: * through the FeatureCvtermDbxref foreign key attribute.
1745: *
1746: * @param FeatureCvtermDbxref $l FeatureCvtermDbxref
1747: * @return Dbxref The current object (for fluent API support)
1748: */
1749: public function addFeatureCvtermDbxref(FeatureCvtermDbxref $l)
1750: {
1751: if ($this->collFeatureCvtermDbxrefs === null) {
1752: $this->initFeatureCvtermDbxrefs();
1753: $this->collFeatureCvtermDbxrefsPartial = true;
1754: }
1755: if (!in_array($l, $this->collFeatureCvtermDbxrefs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1756: $this->doAddFeatureCvtermDbxref($l);
1757: }
1758:
1759: return $this;
1760: }
1761:
1762: /**
1763: * @param FeatureCvtermDbxref $featureCvtermDbxref The featureCvtermDbxref object to add.
1764: */
1765: protected function doAddFeatureCvtermDbxref($featureCvtermDbxref)
1766: {
1767: $this->collFeatureCvtermDbxrefs[]= $featureCvtermDbxref;
1768: $featureCvtermDbxref->setDbxref($this);
1769: }
1770:
1771: /**
1772: * @param FeatureCvtermDbxref $featureCvtermDbxref The featureCvtermDbxref object to remove.
1773: * @return Dbxref The current object (for fluent API support)
1774: */
1775: public function removeFeatureCvtermDbxref($featureCvtermDbxref)
1776: {
1777: if ($this->getFeatureCvtermDbxrefs()->contains($featureCvtermDbxref)) {
1778: $this->collFeatureCvtermDbxrefs->remove($this->collFeatureCvtermDbxrefs->search($featureCvtermDbxref));
1779: if (null === $this->featureCvtermDbxrefsScheduledForDeletion) {
1780: $this->featureCvtermDbxrefsScheduledForDeletion = clone $this->collFeatureCvtermDbxrefs;
1781: $this->featureCvtermDbxrefsScheduledForDeletion->clear();
1782: }
1783: $this->featureCvtermDbxrefsScheduledForDeletion[]= clone $featureCvtermDbxref;
1784: $featureCvtermDbxref->setDbxref(null);
1785: }
1786:
1787: return $this;
1788: }
1789:
1790:
1791: /**
1792: * If this collection has already been initialized with
1793: * an identical criteria, it returns the collection.
1794: * Otherwise if this Dbxref is new, it will return
1795: * an empty collection; or if this Dbxref has previously
1796: * been saved, it will retrieve related FeatureCvtermDbxrefs from storage.
1797: *
1798: * This method is protected by default in order to keep the public
1799: * api reasonable. You can provide public methods for those you
1800: * actually need in Dbxref.
1801: *
1802: * @param Criteria $criteria optional Criteria object to narrow the query
1803: * @param PropelPDO $con optional connection object
1804: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1805: * @return PropelObjectCollection|FeatureCvtermDbxref[] List of FeatureCvtermDbxref objects
1806: */
1807: public function getFeatureCvtermDbxrefsJoinFeatureCvterm($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1808: {
1809: $query = FeatureCvtermDbxrefQuery::create(null, $criteria);
1810: $query->joinWith('FeatureCvterm', $join_behavior);
1811:
1812: return $this->getFeatureCvtermDbxrefs($query, $con);
1813: }
1814:
1815: /**
1816: * Clears out the collFeatureDbxrefs collection
1817: *
1818: * This does not modify the database; however, it will remove any associated objects, causing
1819: * them to be refetched by subsequent calls to accessor method.
1820: *
1821: * @return Dbxref The current object (for fluent API support)
1822: * @see addFeatureDbxrefs()
1823: */
1824: public function clearFeatureDbxrefs()
1825: {
1826: $this->collFeatureDbxrefs = null; // important to set this to null since that means it is uninitialized
1827: $this->collFeatureDbxrefsPartial = null;
1828:
1829: return $this;
1830: }
1831:
1832: /**
1833: * reset is the collFeatureDbxrefs collection loaded partially
1834: *
1835: * @return void
1836: */
1837: public function resetPartialFeatureDbxrefs($v = true)
1838: {
1839: $this->collFeatureDbxrefsPartial = $v;
1840: }
1841:
1842: /**
1843: * Initializes the collFeatureDbxrefs collection.
1844: *
1845: * By default this just sets the collFeatureDbxrefs collection to an empty array (like clearcollFeatureDbxrefs());
1846: * however, you may wish to override this method in your stub class to provide setting appropriate
1847: * to your application -- for example, setting the initial array to the values stored in database.
1848: *
1849: * @param boolean $overrideExisting If set to true, the method call initializes
1850: * the collection even if it is not empty
1851: *
1852: * @return void
1853: */
1854: public function initFeatureDbxrefs($overrideExisting = true)
1855: {
1856: if (null !== $this->collFeatureDbxrefs && !$overrideExisting) {
1857: return;
1858: }
1859: $this->collFeatureDbxrefs = new PropelObjectCollection();
1860: $this->collFeatureDbxrefs->setModel('FeatureDbxref');
1861: }
1862:
1863: /**
1864: * Gets an array of FeatureDbxref objects which contain a foreign key that references this object.
1865: *
1866: * If the $criteria is not null, it is used to always fetch the results from the database.
1867: * Otherwise the results are fetched from the database the first time, then cached.
1868: * Next time the same method is called without $criteria, the cached collection is returned.
1869: * If this Dbxref is new, it will return
1870: * an empty collection or the current collection; the criteria is ignored on a new object.
1871: *
1872: * @param Criteria $criteria optional Criteria object to narrow the query
1873: * @param PropelPDO $con optional connection object
1874: * @return PropelObjectCollection|FeatureDbxref[] List of FeatureDbxref objects
1875: * @throws PropelException
1876: */
1877: public function getFeatureDbxrefs($criteria = null, PropelPDO $con = null)
1878: {
1879: $partial = $this->collFeatureDbxrefsPartial && !$this->isNew();
1880: if (null === $this->collFeatureDbxrefs || null !== $criteria || $partial) {
1881: if ($this->isNew() && null === $this->collFeatureDbxrefs) {
1882: // return empty collection
1883: $this->initFeatureDbxrefs();
1884: } else {
1885: $collFeatureDbxrefs = FeatureDbxrefQuery::create(null, $criteria)
1886: ->filterByDbxref($this)
1887: ->find($con);
1888: if (null !== $criteria) {
1889: if (false !== $this->collFeatureDbxrefsPartial && count($collFeatureDbxrefs)) {
1890: $this->initFeatureDbxrefs(false);
1891:
1892: foreach($collFeatureDbxrefs as $obj) {
1893: if (false == $this->collFeatureDbxrefs->contains($obj)) {
1894: $this->collFeatureDbxrefs->append($obj);
1895: }
1896: }
1897:
1898: $this->collFeatureDbxrefsPartial = true;
1899: }
1900:
1901: $collFeatureDbxrefs->getInternalIterator()->rewind();
1902: return $collFeatureDbxrefs;
1903: }
1904:
1905: if($partial && $this->collFeatureDbxrefs) {
1906: foreach($this->collFeatureDbxrefs as $obj) {
1907: if($obj->isNew()) {
1908: $collFeatureDbxrefs[] = $obj;
1909: }
1910: }
1911: }
1912:
1913: $this->collFeatureDbxrefs = $collFeatureDbxrefs;
1914: $this->collFeatureDbxrefsPartial = false;
1915: }
1916: }
1917:
1918: return $this->collFeatureDbxrefs;
1919: }
1920:
1921: /**
1922: * Sets a collection of FeatureDbxref objects related by a one-to-many relationship
1923: * to the current object.
1924: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1925: * and new objects from the given Propel collection.
1926: *
1927: * @param PropelCollection $featureDbxrefs A Propel collection.
1928: * @param PropelPDO $con Optional connection object
1929: * @return Dbxref The current object (for fluent API support)
1930: */
1931: public function setFeatureDbxrefs(PropelCollection $featureDbxrefs, PropelPDO $con = null)
1932: {
1933: $featureDbxrefsToDelete = $this->getFeatureDbxrefs(new Criteria(), $con)->diff($featureDbxrefs);
1934:
1935: $this->featureDbxrefsScheduledForDeletion = unserialize(serialize($featureDbxrefsToDelete));
1936:
1937: foreach ($featureDbxrefsToDelete as $featureDbxrefRemoved) {
1938: $featureDbxrefRemoved->setDbxref(null);
1939: }
1940:
1941: $this->collFeatureDbxrefs = null;
1942: foreach ($featureDbxrefs as $featureDbxref) {
1943: $this->addFeatureDbxref($featureDbxref);
1944: }
1945:
1946: $this->collFeatureDbxrefs = $featureDbxrefs;
1947: $this->collFeatureDbxrefsPartial = false;
1948:
1949: return $this;
1950: }
1951:
1952: /**
1953: * Returns the number of related FeatureDbxref objects.
1954: *
1955: * @param Criteria $criteria
1956: * @param boolean $distinct
1957: * @param PropelPDO $con
1958: * @return int Count of related FeatureDbxref objects.
1959: * @throws PropelException
1960: */
1961: public function countFeatureDbxrefs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1962: {
1963: $partial = $this->collFeatureDbxrefsPartial && !$this->isNew();
1964: if (null === $this->collFeatureDbxrefs || null !== $criteria || $partial) {
1965: if ($this->isNew() && null === $this->collFeatureDbxrefs) {
1966: return 0;
1967: }
1968:
1969: if($partial && !$criteria) {
1970: return count($this->getFeatureDbxrefs());
1971: }
1972: $query = FeatureDbxrefQuery::create(null, $criteria);
1973: if ($distinct) {
1974: $query->distinct();
1975: }
1976:
1977: return $query
1978: ->filterByDbxref($this)
1979: ->count($con);
1980: }
1981:
1982: return count($this->collFeatureDbxrefs);
1983: }
1984:
1985: /**
1986: * Method called to associate a FeatureDbxref object to this object
1987: * through the FeatureDbxref foreign key attribute.
1988: *
1989: * @param FeatureDbxref $l FeatureDbxref
1990: * @return Dbxref The current object (for fluent API support)
1991: */
1992: public function addFeatureDbxref(FeatureDbxref $l)
1993: {
1994: if ($this->collFeatureDbxrefs === null) {
1995: $this->initFeatureDbxrefs();
1996: $this->collFeatureDbxrefsPartial = true;
1997: }
1998: if (!in_array($l, $this->collFeatureDbxrefs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1999: $this->doAddFeatureDbxref($l);
2000: }
2001:
2002: return $this;
2003: }
2004:
2005: /**
2006: * @param FeatureDbxref $featureDbxref The featureDbxref object to add.
2007: */
2008: protected function doAddFeatureDbxref($featureDbxref)
2009: {
2010: $this->collFeatureDbxrefs[]= $featureDbxref;
2011: $featureDbxref->setDbxref($this);
2012: }
2013:
2014: /**
2015: * @param FeatureDbxref $featureDbxref The featureDbxref object to remove.
2016: * @return Dbxref The current object (for fluent API support)
2017: */
2018: public function removeFeatureDbxref($featureDbxref)
2019: {
2020: if ($this->getFeatureDbxrefs()->contains($featureDbxref)) {
2021: $this->collFeatureDbxrefs->remove($this->collFeatureDbxrefs->search($featureDbxref));
2022: if (null === $this->featureDbxrefsScheduledForDeletion) {
2023: $this->featureDbxrefsScheduledForDeletion = clone $this->collFeatureDbxrefs;
2024: $this->featureDbxrefsScheduledForDeletion->clear();
2025: }
2026: $this->featureDbxrefsScheduledForDeletion[]= clone $featureDbxref;
2027: $featureDbxref->setDbxref(null);
2028: }
2029:
2030: return $this;
2031: }
2032:
2033:
2034: /**
2035: * If this collection has already been initialized with
2036: * an identical criteria, it returns the collection.
2037: * Otherwise if this Dbxref is new, it will return
2038: * an empty collection; or if this Dbxref has previously
2039: * been saved, it will retrieve related FeatureDbxrefs from storage.
2040: *
2041: * This method is protected by default in order to keep the public
2042: * api reasonable. You can provide public methods for those you
2043: * actually need in Dbxref.
2044: *
2045: * @param Criteria $criteria optional Criteria object to narrow the query
2046: * @param PropelPDO $con optional connection object
2047: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2048: * @return PropelObjectCollection|FeatureDbxref[] List of FeatureDbxref objects
2049: */
2050: public function getFeatureDbxrefsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2051: {
2052: $query = FeatureDbxrefQuery::create(null, $criteria);
2053: $query->joinWith('Feature', $join_behavior);
2054:
2055: return $this->getFeatureDbxrefs($query, $con);
2056: }
2057:
2058: /**
2059: * Clears out the collPubDbxrefs collection
2060: *
2061: * This does not modify the database; however, it will remove any associated objects, causing
2062: * them to be refetched by subsequent calls to accessor method.
2063: *
2064: * @return Dbxref The current object (for fluent API support)
2065: * @see addPubDbxrefs()
2066: */
2067: public function clearPubDbxrefs()
2068: {
2069: $this->collPubDbxrefs = null; // important to set this to null since that means it is uninitialized
2070: $this->collPubDbxrefsPartial = null;
2071:
2072: return $this;
2073: }
2074:
2075: /**
2076: * reset is the collPubDbxrefs collection loaded partially
2077: *
2078: * @return void
2079: */
2080: public function resetPartialPubDbxrefs($v = true)
2081: {
2082: $this->collPubDbxrefsPartial = $v;
2083: }
2084:
2085: /**
2086: * Initializes the collPubDbxrefs collection.
2087: *
2088: * By default this just sets the collPubDbxrefs collection to an empty array (like clearcollPubDbxrefs());
2089: * however, you may wish to override this method in your stub class to provide setting appropriate
2090: * to your application -- for example, setting the initial array to the values stored in database.
2091: *
2092: * @param boolean $overrideExisting If set to true, the method call initializes
2093: * the collection even if it is not empty
2094: *
2095: * @return void
2096: */
2097: public function initPubDbxrefs($overrideExisting = true)
2098: {
2099: if (null !== $this->collPubDbxrefs && !$overrideExisting) {
2100: return;
2101: }
2102: $this->collPubDbxrefs = new PropelObjectCollection();
2103: $this->collPubDbxrefs->setModel('PubDbxref');
2104: }
2105:
2106: /**
2107: * Gets an array of PubDbxref objects which contain a foreign key that references this object.
2108: *
2109: * If the $criteria is not null, it is used to always fetch the results from the database.
2110: * Otherwise the results are fetched from the database the first time, then cached.
2111: * Next time the same method is called without $criteria, the cached collection is returned.
2112: * If this Dbxref is new, it will return
2113: * an empty collection or the current collection; the criteria is ignored on a new object.
2114: *
2115: * @param Criteria $criteria optional Criteria object to narrow the query
2116: * @param PropelPDO $con optional connection object
2117: * @return PropelObjectCollection|PubDbxref[] List of PubDbxref objects
2118: * @throws PropelException
2119: */
2120: public function getPubDbxrefs($criteria = null, PropelPDO $con = null)
2121: {
2122: $partial = $this->collPubDbxrefsPartial && !$this->isNew();
2123: if (null === $this->collPubDbxrefs || null !== $criteria || $partial) {
2124: if ($this->isNew() && null === $this->collPubDbxrefs) {
2125: // return empty collection
2126: $this->initPubDbxrefs();
2127: } else {
2128: $collPubDbxrefs = PubDbxrefQuery::create(null, $criteria)
2129: ->filterByDbxref($this)
2130: ->find($con);
2131: if (null !== $criteria) {
2132: if (false !== $this->collPubDbxrefsPartial && count($collPubDbxrefs)) {
2133: $this->initPubDbxrefs(false);
2134:
2135: foreach($collPubDbxrefs as $obj) {
2136: if (false == $this->collPubDbxrefs->contains($obj)) {
2137: $this->collPubDbxrefs->append($obj);
2138: }
2139: }
2140:
2141: $this->collPubDbxrefsPartial = true;
2142: }
2143:
2144: $collPubDbxrefs->getInternalIterator()->rewind();
2145: return $collPubDbxrefs;
2146: }
2147:
2148: if($partial && $this->collPubDbxrefs) {
2149: foreach($this->collPubDbxrefs as $obj) {
2150: if($obj->isNew()) {
2151: $collPubDbxrefs[] = $obj;
2152: }
2153: }
2154: }
2155:
2156: $this->collPubDbxrefs = $collPubDbxrefs;
2157: $this->collPubDbxrefsPartial = false;
2158: }
2159: }
2160:
2161: return $this->collPubDbxrefs;
2162: }
2163:
2164: /**
2165: * Sets a collection of PubDbxref objects related by a one-to-many relationship
2166: * to the current object.
2167: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2168: * and new objects from the given Propel collection.
2169: *
2170: * @param PropelCollection $pubDbxrefs A Propel collection.
2171: * @param PropelPDO $con Optional connection object
2172: * @return Dbxref The current object (for fluent API support)
2173: */
2174: public function setPubDbxrefs(PropelCollection $pubDbxrefs, PropelPDO $con = null)
2175: {
2176: $pubDbxrefsToDelete = $this->getPubDbxrefs(new Criteria(), $con)->diff($pubDbxrefs);
2177:
2178: $this->pubDbxrefsScheduledForDeletion = unserialize(serialize($pubDbxrefsToDelete));
2179:
2180: foreach ($pubDbxrefsToDelete as $pubDbxrefRemoved) {
2181: $pubDbxrefRemoved->setDbxref(null);
2182: }
2183:
2184: $this->collPubDbxrefs = null;
2185: foreach ($pubDbxrefs as $pubDbxref) {
2186: $this->addPubDbxref($pubDbxref);
2187: }
2188:
2189: $this->collPubDbxrefs = $pubDbxrefs;
2190: $this->collPubDbxrefsPartial = false;
2191:
2192: return $this;
2193: }
2194:
2195: /**
2196: * Returns the number of related PubDbxref objects.
2197: *
2198: * @param Criteria $criteria
2199: * @param boolean $distinct
2200: * @param PropelPDO $con
2201: * @return int Count of related PubDbxref objects.
2202: * @throws PropelException
2203: */
2204: public function countPubDbxrefs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2205: {
2206: $partial = $this->collPubDbxrefsPartial && !$this->isNew();
2207: if (null === $this->collPubDbxrefs || null !== $criteria || $partial) {
2208: if ($this->isNew() && null === $this->collPubDbxrefs) {
2209: return 0;
2210: }
2211:
2212: if($partial && !$criteria) {
2213: return count($this->getPubDbxrefs());
2214: }
2215: $query = PubDbxrefQuery::create(null, $criteria);
2216: if ($distinct) {
2217: $query->distinct();
2218: }
2219:
2220: return $query
2221: ->filterByDbxref($this)
2222: ->count($con);
2223: }
2224:
2225: return count($this->collPubDbxrefs);
2226: }
2227:
2228: /**
2229: * Method called to associate a PubDbxref object to this object
2230: * through the PubDbxref foreign key attribute.
2231: *
2232: * @param PubDbxref $l PubDbxref
2233: * @return Dbxref The current object (for fluent API support)
2234: */
2235: public function addPubDbxref(PubDbxref $l)
2236: {
2237: if ($this->collPubDbxrefs === null) {
2238: $this->initPubDbxrefs();
2239: $this->collPubDbxrefsPartial = true;
2240: }
2241: if (!in_array($l, $this->collPubDbxrefs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2242: $this->doAddPubDbxref($l);
2243: }
2244:
2245: return $this;
2246: }
2247:
2248: /**
2249: * @param PubDbxref $pubDbxref The pubDbxref object to add.
2250: */
2251: protected function doAddPubDbxref($pubDbxref)
2252: {
2253: $this->collPubDbxrefs[]= $pubDbxref;
2254: $pubDbxref->setDbxref($this);
2255: }
2256:
2257: /**
2258: * @param PubDbxref $pubDbxref The pubDbxref object to remove.
2259: * @return Dbxref The current object (for fluent API support)
2260: */
2261: public function removePubDbxref($pubDbxref)
2262: {
2263: if ($this->getPubDbxrefs()->contains($pubDbxref)) {
2264: $this->collPubDbxrefs->remove($this->collPubDbxrefs->search($pubDbxref));
2265: if (null === $this->pubDbxrefsScheduledForDeletion) {
2266: $this->pubDbxrefsScheduledForDeletion = clone $this->collPubDbxrefs;
2267: $this->pubDbxrefsScheduledForDeletion->clear();
2268: }
2269: $this->pubDbxrefsScheduledForDeletion[]= clone $pubDbxref;
2270: $pubDbxref->setDbxref(null);
2271: }
2272:
2273: return $this;
2274: }
2275:
2276:
2277: /**
2278: * If this collection has already been initialized with
2279: * an identical criteria, it returns the collection.
2280: * Otherwise if this Dbxref is new, it will return
2281: * an empty collection; or if this Dbxref has previously
2282: * been saved, it will retrieve related PubDbxrefs from storage.
2283: *
2284: * This method is protected by default in order to keep the public
2285: * api reasonable. You can provide public methods for those you
2286: * actually need in Dbxref.
2287: *
2288: * @param Criteria $criteria optional Criteria object to narrow the query
2289: * @param PropelPDO $con optional connection object
2290: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2291: * @return PropelObjectCollection|PubDbxref[] List of PubDbxref objects
2292: */
2293: public function getPubDbxrefsJoinPub($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2294: {
2295: $query = PubDbxrefQuery::create(null, $criteria);
2296: $query->joinWith('Pub', $join_behavior);
2297:
2298: return $this->getPubDbxrefs($query, $con);
2299: }
2300:
2301: /**
2302: * Clears the current object and sets all attributes to their default values
2303: */
2304: public function clear()
2305: {
2306: $this->dbxref_id = null;
2307: $this->db_id = null;
2308: $this->accession = null;
2309: $this->version = null;
2310: $this->description = null;
2311: $this->alreadyInSave = false;
2312: $this->alreadyInValidation = false;
2313: $this->alreadyInClearAllReferencesDeep = false;
2314: $this->clearAllReferences();
2315: $this->applyDefaultValues();
2316: $this->resetModified();
2317: $this->setNew(true);
2318: $this->setDeleted(false);
2319: }
2320:
2321: /**
2322: * Resets all references to other model objects or collections of model objects.
2323: *
2324: * This method is a user-space workaround for PHP's inability to garbage collect
2325: * objects with circular references (even in PHP 5.3). This is currently necessary
2326: * when using Propel in certain daemon or large-volumne/high-memory operations.
2327: *
2328: * @param boolean $deep Whether to also clear the references on all referrer objects.
2329: */
2330: public function clearAllReferences($deep = false)
2331: {
2332: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
2333: $this->alreadyInClearAllReferencesDeep = true;
2334: if ($this->collFeatures) {
2335: foreach ($this->collFeatures as $o) {
2336: $o->clearAllReferences($deep);
2337: }
2338: }
2339: if ($this->collFeatureCvtermDbxrefs) {
2340: foreach ($this->collFeatureCvtermDbxrefs as $o) {
2341: $o->clearAllReferences($deep);
2342: }
2343: }
2344: if ($this->collFeatureDbxrefs) {
2345: foreach ($this->collFeatureDbxrefs as $o) {
2346: $o->clearAllReferences($deep);
2347: }
2348: }
2349: if ($this->collPubDbxrefs) {
2350: foreach ($this->collPubDbxrefs as $o) {
2351: $o->clearAllReferences($deep);
2352: }
2353: }
2354: if ($this->aDb instanceof Persistent) {
2355: $this->aDb->clearAllReferences($deep);
2356: }
2357:
2358: $this->alreadyInClearAllReferencesDeep = false;
2359: } // if ($deep)
2360:
2361: if ($this->collFeatures instanceof PropelCollection) {
2362: $this->collFeatures->clearIterator();
2363: }
2364: $this->collFeatures = null;
2365: if ($this->collFeatureCvtermDbxrefs instanceof PropelCollection) {
2366: $this->collFeatureCvtermDbxrefs->clearIterator();
2367: }
2368: $this->collFeatureCvtermDbxrefs = null;
2369: if ($this->collFeatureDbxrefs instanceof PropelCollection) {
2370: $this->collFeatureDbxrefs->clearIterator();
2371: }
2372: $this->collFeatureDbxrefs = null;
2373: if ($this->collPubDbxrefs instanceof PropelCollection) {
2374: $this->collPubDbxrefs->clearIterator();
2375: }
2376: $this->collPubDbxrefs = null;
2377: $this->aDb = null;
2378: }
2379:
2380: /**
2381: * return the string representation of this object
2382: *
2383: * @return string
2384: */
2385: public function __toString()
2386: {
2387: return (string) $this->exportTo(DbxrefPeer::DEFAULT_STRING_FORMAT);
2388: }
2389:
2390: /**
2391: * return true is the object is in saving state
2392: *
2393: * @return boolean
2394: */
2395: public function isAlreadyInSave()
2396: {
2397: return $this->alreadyInSave;
2398: }
2399:
2400: }
2401: