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 \PropelException;
13: use \PropelPDO;
14: use cli_db\propel\Dbxref;
15: use cli_db\propel\DbxrefQuery;
16: use cli_db\propel\Feature;
17: use cli_db\propel\FeatureDbxref;
18: use cli_db\propel\FeatureDbxrefPeer;
19: use cli_db\propel\FeatureDbxrefQuery;
20: use cli_db\propel\FeatureQuery;
21:
22: /**
23: * Base class that represents a row from the 'feature_dbxref' table.
24: *
25: *
26: *
27: * @package propel.generator.cli_db.om
28: */
29: abstract class BaseFeatureDbxref extends BaseObject implements Persistent
30: {
31: /**
32: * Peer class name
33: */
34: const PEER = 'cli_db\\propel\\FeatureDbxrefPeer';
35:
36: /**
37: * The Peer class.
38: * Instance provides a convenient way of calling static methods on a class
39: * that calling code may not be able to identify.
40: * @var FeatureDbxrefPeer
41: */
42: protected static $peer;
43:
44: /**
45: * The flag var to prevent infinit loop in deep copy
46: * @var boolean
47: */
48: protected $startCopy = false;
49:
50: /**
51: * The value for the feature_dbxref_id field.
52: * @var int
53: */
54: protected $feature_dbxref_id;
55:
56: /**
57: * The value for the feature_id field.
58: * @var int
59: */
60: protected $feature_id;
61:
62: /**
63: * The value for the dbxref_id field.
64: * @var int
65: */
66: protected $dbxref_id;
67:
68: /**
69: * The value for the is_current field.
70: * Note: this column has a database default value of: true
71: * @var boolean
72: */
73: protected $is_current;
74:
75: /**
76: * @var Dbxref
77: */
78: protected $aDbxref;
79:
80: /**
81: * @var Feature
82: */
83: protected $aFeature;
84:
85: /**
86: * Flag to prevent endless save loop, if this object is referenced
87: * by another object which falls in this transaction.
88: * @var boolean
89: */
90: protected $alreadyInSave = false;
91:
92: /**
93: * Flag to prevent endless validation loop, if this object is referenced
94: * by another object which falls in this transaction.
95: * @var boolean
96: */
97: protected $alreadyInValidation = false;
98:
99: /**
100: * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
101: * @var boolean
102: */
103: protected $alreadyInClearAllReferencesDeep = false;
104:
105: /**
106: * Applies default values to this object.
107: * This method should be called from the object's constructor (or
108: * equivalent initialization method).
109: * @see __construct()
110: */
111: public function applyDefaultValues()
112: {
113: $this->is_current = true;
114: }
115:
116: /**
117: * Initializes internal state of BaseFeatureDbxref object.
118: * @see applyDefaults()
119: */
120: public function __construct()
121: {
122: parent::__construct();
123: $this->applyDefaultValues();
124: }
125:
126: /**
127: * Get the [feature_dbxref_id] column value.
128: *
129: * @return int
130: */
131: public function getFeatureDbxrefId()
132: {
133: return $this->feature_dbxref_id;
134: }
135:
136: /**
137: * Get the [feature_id] column value.
138: *
139: * @return int
140: */
141: public function getFeatureId()
142: {
143: return $this->feature_id;
144: }
145:
146: /**
147: * Get the [dbxref_id] column value.
148: *
149: * @return int
150: */
151: public function getDbxrefId()
152: {
153: return $this->dbxref_id;
154: }
155:
156: /**
157: * Get the [is_current] column value.
158: *
159: * @return boolean
160: */
161: public function getIsCurrent()
162: {
163: return $this->is_current;
164: }
165:
166: /**
167: * Set the value of [feature_dbxref_id] column.
168: *
169: * @param int $v new value
170: * @return FeatureDbxref The current object (for fluent API support)
171: */
172: public function setFeatureDbxrefId($v)
173: {
174: if ($v !== null && is_numeric($v)) {
175: $v = (int) $v;
176: }
177:
178: if ($this->feature_dbxref_id !== $v) {
179: $this->feature_dbxref_id = $v;
180: $this->modifiedColumns[] = FeatureDbxrefPeer::FEATURE_DBXREF_ID;
181: }
182:
183:
184: return $this;
185: } // setFeatureDbxrefId()
186:
187: /**
188: * Set the value of [feature_id] column.
189: *
190: * @param int $v new value
191: * @return FeatureDbxref The current object (for fluent API support)
192: */
193: public function setFeatureId($v)
194: {
195: if ($v !== null && is_numeric($v)) {
196: $v = (int) $v;
197: }
198:
199: if ($this->feature_id !== $v) {
200: $this->feature_id = $v;
201: $this->modifiedColumns[] = FeatureDbxrefPeer::FEATURE_ID;
202: }
203:
204: if ($this->aFeature !== null && $this->aFeature->getFeatureId() !== $v) {
205: $this->aFeature = null;
206: }
207:
208:
209: return $this;
210: } // setFeatureId()
211:
212: /**
213: * Set the value of [dbxref_id] column.
214: *
215: * @param int $v new value
216: * @return FeatureDbxref The current object (for fluent API support)
217: */
218: public function setDbxrefId($v)
219: {
220: if ($v !== null && is_numeric($v)) {
221: $v = (int) $v;
222: }
223:
224: if ($this->dbxref_id !== $v) {
225: $this->dbxref_id = $v;
226: $this->modifiedColumns[] = FeatureDbxrefPeer::DBXREF_ID;
227: }
228:
229: if ($this->aDbxref !== null && $this->aDbxref->getDbxrefId() !== $v) {
230: $this->aDbxref = null;
231: }
232:
233:
234: return $this;
235: } // setDbxrefId()
236:
237: /**
238: * Sets the value of the [is_current] column.
239: * Non-boolean arguments are converted using the following rules:
240: * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
241: * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
242: * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
243: *
244: * @param boolean|integer|string $v The new value
245: * @return FeatureDbxref The current object (for fluent API support)
246: */
247: public function setIsCurrent($v)
248: {
249: if ($v !== null) {
250: if (is_string($v)) {
251: $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
252: } else {
253: $v = (boolean) $v;
254: }
255: }
256:
257: if ($this->is_current !== $v) {
258: $this->is_current = $v;
259: $this->modifiedColumns[] = FeatureDbxrefPeer::IS_CURRENT;
260: }
261:
262:
263: return $this;
264: } // setIsCurrent()
265:
266: /**
267: * Indicates whether the columns in this object are only set to default values.
268: *
269: * This method can be used in conjunction with isModified() to indicate whether an object is both
270: * modified _and_ has some values set which are non-default.
271: *
272: * @return boolean Whether the columns in this object are only been set with default values.
273: */
274: public function hasOnlyDefaultValues()
275: {
276: if ($this->is_current !== true) {
277: return false;
278: }
279:
280: // otherwise, everything was equal, so return true
281: return true;
282: } // hasOnlyDefaultValues()
283:
284: /**
285: * Hydrates (populates) the object variables with values from the database resultset.
286: *
287: * An offset (0-based "start column") is specified so that objects can be hydrated
288: * with a subset of the columns in the resultset rows. This is needed, for example,
289: * for results of JOIN queries where the resultset row includes columns from two or
290: * more tables.
291: *
292: * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
293: * @param int $startcol 0-based offset column which indicates which restultset column to start with.
294: * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
295: * @return int next starting column
296: * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
297: */
298: public function hydrate($row, $startcol = 0, $rehydrate = false)
299: {
300: try {
301:
302: $this->feature_dbxref_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
303: $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
304: $this->dbxref_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
305: $this->is_current = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null;
306: $this->resetModified();
307:
308: $this->setNew(false);
309:
310: if ($rehydrate) {
311: $this->ensureConsistency();
312: }
313: $this->postHydrate($row, $startcol, $rehydrate);
314: return $startcol + 4; // 4 = FeatureDbxrefPeer::NUM_HYDRATE_COLUMNS.
315:
316: } catch (Exception $e) {
317: throw new PropelException("Error populating FeatureDbxref object", $e);
318: }
319: }
320:
321: /**
322: * Checks and repairs the internal consistency of the object.
323: *
324: * This method is executed after an already-instantiated object is re-hydrated
325: * from the database. It exists to check any foreign keys to make sure that
326: * the objects related to the current object are correct based on foreign key.
327: *
328: * You can override this method in the stub class, but you should always invoke
329: * the base method from the overridden method (i.e. parent::ensureConsistency()),
330: * in case your model changes.
331: *
332: * @throws PropelException
333: */
334: public function ensureConsistency()
335: {
336:
337: if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getFeatureId()) {
338: $this->aFeature = null;
339: }
340: if ($this->aDbxref !== null && $this->dbxref_id !== $this->aDbxref->getDbxrefId()) {
341: $this->aDbxref = null;
342: }
343: } // ensureConsistency
344:
345: /**
346: * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
347: *
348: * This will only work if the object has been saved and has a valid primary key set.
349: *
350: * @param boolean $deep (optional) Whether to also de-associated any related objects.
351: * @param PropelPDO $con (optional) The PropelPDO connection to use.
352: * @return void
353: * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
354: */
355: public function reload($deep = false, PropelPDO $con = null)
356: {
357: if ($this->isDeleted()) {
358: throw new PropelException("Cannot reload a deleted object.");
359: }
360:
361: if ($this->isNew()) {
362: throw new PropelException("Cannot reload an unsaved object.");
363: }
364:
365: if ($con === null) {
366: $con = Propel::getConnection(FeatureDbxrefPeer::DATABASE_NAME, Propel::CONNECTION_READ);
367: }
368:
369: // We don't need to alter the object instance pool; we're just modifying this instance
370: // already in the pool.
371:
372: $stmt = FeatureDbxrefPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
373: $row = $stmt->fetch(PDO::FETCH_NUM);
374: $stmt->closeCursor();
375: if (!$row) {
376: throw new PropelException('Cannot find matching row in the database to reload object values.');
377: }
378: $this->hydrate($row, 0, true); // rehydrate
379:
380: if ($deep) { // also de-associate any related objects?
381:
382: $this->aDbxref = null;
383: $this->aFeature = null;
384: } // if (deep)
385: }
386:
387: /**
388: * Removes this object from datastore and sets delete attribute.
389: *
390: * @param PropelPDO $con
391: * @return void
392: * @throws PropelException
393: * @throws Exception
394: * @see BaseObject::setDeleted()
395: * @see BaseObject::isDeleted()
396: */
397: public function delete(PropelPDO $con = null)
398: {
399: if ($this->isDeleted()) {
400: throw new PropelException("This object has already been deleted.");
401: }
402:
403: if ($con === null) {
404: $con = Propel::getConnection(FeatureDbxrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
405: }
406:
407: $con->beginTransaction();
408: try {
409: $deleteQuery = FeatureDbxrefQuery::create()
410: ->filterByPrimaryKey($this->getPrimaryKey());
411: $ret = $this->preDelete($con);
412: if ($ret) {
413: $deleteQuery->delete($con);
414: $this->postDelete($con);
415: $con->commit();
416: $this->setDeleted(true);
417: } else {
418: $con->commit();
419: }
420: } catch (Exception $e) {
421: $con->rollBack();
422: throw $e;
423: }
424: }
425:
426: /**
427: * Persists this object to the database.
428: *
429: * If the object is new, it inserts it; otherwise an update is performed.
430: * All modified related objects will also be persisted in the doSave()
431: * method. This method wraps all precipitate database operations in a
432: * single transaction.
433: *
434: * @param PropelPDO $con
435: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
436: * @throws PropelException
437: * @throws Exception
438: * @see doSave()
439: */
440: public function save(PropelPDO $con = null)
441: {
442: if ($this->isDeleted()) {
443: throw new PropelException("You cannot save an object that has been deleted.");
444: }
445:
446: if ($con === null) {
447: $con = Propel::getConnection(FeatureDbxrefPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
448: }
449:
450: $con->beginTransaction();
451: $isInsert = $this->isNew();
452: try {
453: $ret = $this->preSave($con);
454: if ($isInsert) {
455: $ret = $ret && $this->preInsert($con);
456: } else {
457: $ret = $ret && $this->preUpdate($con);
458: }
459: if ($ret) {
460: $affectedRows = $this->doSave($con);
461: if ($isInsert) {
462: $this->postInsert($con);
463: } else {
464: $this->postUpdate($con);
465: }
466: $this->postSave($con);
467: FeatureDbxrefPeer::addInstanceToPool($this);
468: } else {
469: $affectedRows = 0;
470: }
471: $con->commit();
472:
473: return $affectedRows;
474: } catch (Exception $e) {
475: $con->rollBack();
476: throw $e;
477: }
478: }
479:
480: /**
481: * Performs the work of inserting or updating the row in the database.
482: *
483: * If the object is new, it inserts it; otherwise an update is performed.
484: * All related objects are also updated in this method.
485: *
486: * @param PropelPDO $con
487: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
488: * @throws PropelException
489: * @see save()
490: */
491: protected function doSave(PropelPDO $con)
492: {
493: $affectedRows = 0; // initialize var to track total num of affected rows
494: if (!$this->alreadyInSave) {
495: $this->alreadyInSave = true;
496:
497: // We call the save method on the following object(s) if they
498: // were passed to this object by their coresponding set
499: // method. This object relates to these object(s) by a
500: // foreign key reference.
501:
502: if ($this->aDbxref !== null) {
503: if ($this->aDbxref->isModified() || $this->aDbxref->isNew()) {
504: $affectedRows += $this->aDbxref->save($con);
505: }
506: $this->setDbxref($this->aDbxref);
507: }
508:
509: if ($this->aFeature !== null) {
510: if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
511: $affectedRows += $this->aFeature->save($con);
512: }
513: $this->setFeature($this->aFeature);
514: }
515:
516: if ($this->isNew() || $this->isModified()) {
517: // persist changes
518: if ($this->isNew()) {
519: $this->doInsert($con);
520: } else {
521: $this->doUpdate($con);
522: }
523: $affectedRows += 1;
524: $this->resetModified();
525: }
526:
527: $this->alreadyInSave = false;
528:
529: }
530:
531: return $affectedRows;
532: } // doSave()
533:
534: /**
535: * Insert the row in the database.
536: *
537: * @param PropelPDO $con
538: *
539: * @throws PropelException
540: * @see doSave()
541: */
542: protected function doInsert(PropelPDO $con)
543: {
544: $modifiedColumns = array();
545: $index = 0;
546:
547: $this->modifiedColumns[] = FeatureDbxrefPeer::FEATURE_DBXREF_ID;
548: if (null !== $this->feature_dbxref_id) {
549: throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureDbxrefPeer::FEATURE_DBXREF_ID . ')');
550: }
551: if (null === $this->feature_dbxref_id) {
552: try {
553: $stmt = $con->query("SELECT nextval('feature_dbxref_feature_dbxref_id_seq')");
554: $row = $stmt->fetch(PDO::FETCH_NUM);
555: $this->feature_dbxref_id = $row[0];
556: } catch (Exception $e) {
557: throw new PropelException('Unable to get sequence id.', $e);
558: }
559: }
560:
561:
562: // check the columns in natural order for more readable SQL queries
563: if ($this->isColumnModified(FeatureDbxrefPeer::FEATURE_DBXREF_ID)) {
564: $modifiedColumns[':p' . $index++] = '"feature_dbxref_id"';
565: }
566: if ($this->isColumnModified(FeatureDbxrefPeer::FEATURE_ID)) {
567: $modifiedColumns[':p' . $index++] = '"feature_id"';
568: }
569: if ($this->isColumnModified(FeatureDbxrefPeer::DBXREF_ID)) {
570: $modifiedColumns[':p' . $index++] = '"dbxref_id"';
571: }
572: if ($this->isColumnModified(FeatureDbxrefPeer::IS_CURRENT)) {
573: $modifiedColumns[':p' . $index++] = '"is_current"';
574: }
575:
576: $sql = sprintf(
577: 'INSERT INTO "feature_dbxref" (%s) VALUES (%s)',
578: implode(', ', $modifiedColumns),
579: implode(', ', array_keys($modifiedColumns))
580: );
581:
582: try {
583: $stmt = $con->prepare($sql);
584: foreach ($modifiedColumns as $identifier => $columnName) {
585: switch ($columnName) {
586: case '"feature_dbxref_id"':
587: $stmt->bindValue($identifier, $this->feature_dbxref_id, PDO::PARAM_INT);
588: break;
589: case '"feature_id"':
590: $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
591: break;
592: case '"dbxref_id"':
593: $stmt->bindValue($identifier, $this->dbxref_id, PDO::PARAM_INT);
594: break;
595: case '"is_current"':
596: $stmt->bindValue($identifier, $this->is_current, PDO::PARAM_BOOL);
597: break;
598: }
599: }
600: $stmt->execute();
601: } catch (Exception $e) {
602: Propel::log($e->getMessage(), Propel::LOG_ERR);
603: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
604: }
605:
606: $this->setNew(false);
607: }
608:
609: /**
610: * Update the row in the database.
611: *
612: * @param PropelPDO $con
613: *
614: * @see doSave()
615: */
616: protected function doUpdate(PropelPDO $con)
617: {
618: $selectCriteria = $this->buildPkeyCriteria();
619: $valuesCriteria = $this->buildCriteria();
620: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
621: }
622:
623: /**
624: * Array of ValidationFailed objects.
625: * @var array ValidationFailed[]
626: */
627: protected $validationFailures = array();
628:
629: /**
630: * Gets any ValidationFailed objects that resulted from last call to validate().
631: *
632: *
633: * @return array ValidationFailed[]
634: * @see validate()
635: */
636: public function getValidationFailures()
637: {
638: return $this->validationFailures;
639: }
640:
641: /**
642: * Validates the objects modified field values and all objects related to this table.
643: *
644: * If $columns is either a column name or an array of column names
645: * only those columns are validated.
646: *
647: * @param mixed $columns Column name or an array of column names.
648: * @return boolean Whether all columns pass validation.
649: * @see doValidate()
650: * @see getValidationFailures()
651: */
652: public function validate($columns = null)
653: {
654: $res = $this->doValidate($columns);
655: if ($res === true) {
656: $this->validationFailures = array();
657:
658: return true;
659: }
660:
661: $this->validationFailures = $res;
662:
663: return false;
664: }
665:
666: /**
667: * This function performs the validation work for complex object models.
668: *
669: * In addition to checking the current object, all related objects will
670: * also be validated. If all pass then <code>true</code> is returned; otherwise
671: * an aggreagated array of ValidationFailed objects will be returned.
672: *
673: * @param array $columns Array of column names to validate.
674: * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
675: */
676: protected function doValidate($columns = null)
677: {
678: if (!$this->alreadyInValidation) {
679: $this->alreadyInValidation = true;
680: $retval = null;
681:
682: $failureMap = array();
683:
684:
685: // We call the validate method on the following object(s) if they
686: // were passed to this object by their coresponding set
687: // method. This object relates to these object(s) by a
688: // foreign key reference.
689:
690: if ($this->aDbxref !== null) {
691: if (!$this->aDbxref->validate($columns)) {
692: $failureMap = array_merge($failureMap, $this->aDbxref->getValidationFailures());
693: }
694: }
695:
696: if ($this->aFeature !== null) {
697: if (!$this->aFeature->validate($columns)) {
698: $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures());
699: }
700: }
701:
702:
703: if (($retval = FeatureDbxrefPeer::doValidate($this, $columns)) !== true) {
704: $failureMap = array_merge($failureMap, $retval);
705: }
706:
707:
708:
709: $this->alreadyInValidation = false;
710: }
711:
712: return (!empty($failureMap) ? $failureMap : true);
713: }
714:
715: /**
716: * Retrieves a field from the object by name passed in as a string.
717: *
718: * @param string $name name
719: * @param string $type The type of fieldname the $name is of:
720: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
721: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
722: * Defaults to BasePeer::TYPE_PHPNAME
723: * @return mixed Value of field.
724: */
725: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
726: {
727: $pos = FeatureDbxrefPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
728: $field = $this->getByPosition($pos);
729:
730: return $field;
731: }
732:
733: /**
734: * Retrieves a field from the object by Position as specified in the xml schema.
735: * Zero-based.
736: *
737: * @param int $pos position in xml schema
738: * @return mixed Value of field at $pos
739: */
740: public function getByPosition($pos)
741: {
742: switch ($pos) {
743: case 0:
744: return $this->getFeatureDbxrefId();
745: break;
746: case 1:
747: return $this->getFeatureId();
748: break;
749: case 2:
750: return $this->getDbxrefId();
751: break;
752: case 3:
753: return $this->getIsCurrent();
754: break;
755: default:
756: return null;
757: break;
758: } // switch()
759: }
760:
761: /**
762: * Exports the object as an array.
763: *
764: * You can specify the key type of the array by passing one of the class
765: * type constants.
766: *
767: * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
768: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
769: * Defaults to BasePeer::TYPE_PHPNAME.
770: * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
771: * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
772: * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
773: *
774: * @return array an associative array containing the field names (as keys) and field values
775: */
776: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
777: {
778: if (isset($alreadyDumpedObjects['FeatureDbxref'][$this->getPrimaryKey()])) {
779: return '*RECURSION*';
780: }
781: $alreadyDumpedObjects['FeatureDbxref'][$this->getPrimaryKey()] = true;
782: $keys = FeatureDbxrefPeer::getFieldNames($keyType);
783: $result = array(
784: $keys[0] => $this->getFeatureDbxrefId(),
785: $keys[1] => $this->getFeatureId(),
786: $keys[2] => $this->getDbxrefId(),
787: $keys[3] => $this->getIsCurrent(),
788: );
789: if ($includeForeignObjects) {
790: if (null !== $this->aDbxref) {
791: $result['Dbxref'] = $this->aDbxref->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
792: }
793: if (null !== $this->aFeature) {
794: $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
795: }
796: }
797:
798: return $result;
799: }
800:
801: /**
802: * Sets a field from the object by name passed in as a string.
803: *
804: * @param string $name peer name
805: * @param mixed $value field value
806: * @param string $type The type of fieldname the $name is of:
807: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
808: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
809: * Defaults to BasePeer::TYPE_PHPNAME
810: * @return void
811: */
812: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
813: {
814: $pos = FeatureDbxrefPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
815:
816: $this->setByPosition($pos, $value);
817: }
818:
819: /**
820: * Sets a field from the object by Position as specified in the xml schema.
821: * Zero-based.
822: *
823: * @param int $pos position in xml schema
824: * @param mixed $value field value
825: * @return void
826: */
827: public function setByPosition($pos, $value)
828: {
829: switch ($pos) {
830: case 0:
831: $this->setFeatureDbxrefId($value);
832: break;
833: case 1:
834: $this->setFeatureId($value);
835: break;
836: case 2:
837: $this->setDbxrefId($value);
838: break;
839: case 3:
840: $this->setIsCurrent($value);
841: break;
842: } // switch()
843: }
844:
845: /**
846: * Populates the object using an array.
847: *
848: * This is particularly useful when populating an object from one of the
849: * request arrays (e.g. $_POST). This method goes through the column
850: * names, checking to see whether a matching key exists in populated
851: * array. If so the setByName() method is called for that column.
852: *
853: * You can specify the key type of the array by additionally passing one
854: * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
855: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
856: * The default key type is the column's BasePeer::TYPE_PHPNAME
857: *
858: * @param array $arr An array to populate the object from.
859: * @param string $keyType The type of keys the array uses.
860: * @return void
861: */
862: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
863: {
864: $keys = FeatureDbxrefPeer::getFieldNames($keyType);
865:
866: if (array_key_exists($keys[0], $arr)) $this->setFeatureDbxrefId($arr[$keys[0]]);
867: if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
868: if (array_key_exists($keys[2], $arr)) $this->setDbxrefId($arr[$keys[2]]);
869: if (array_key_exists($keys[3], $arr)) $this->setIsCurrent($arr[$keys[3]]);
870: }
871:
872: /**
873: * Build a Criteria object containing the values of all modified columns in this object.
874: *
875: * @return Criteria The Criteria object containing all modified values.
876: */
877: public function buildCriteria()
878: {
879: $criteria = new Criteria(FeatureDbxrefPeer::DATABASE_NAME);
880:
881: if ($this->isColumnModified(FeatureDbxrefPeer::FEATURE_DBXREF_ID)) $criteria->add(FeatureDbxrefPeer::FEATURE_DBXREF_ID, $this->feature_dbxref_id);
882: if ($this->isColumnModified(FeatureDbxrefPeer::FEATURE_ID)) $criteria->add(FeatureDbxrefPeer::FEATURE_ID, $this->feature_id);
883: if ($this->isColumnModified(FeatureDbxrefPeer::DBXREF_ID)) $criteria->add(FeatureDbxrefPeer::DBXREF_ID, $this->dbxref_id);
884: if ($this->isColumnModified(FeatureDbxrefPeer::IS_CURRENT)) $criteria->add(FeatureDbxrefPeer::IS_CURRENT, $this->is_current);
885:
886: return $criteria;
887: }
888:
889: /**
890: * Builds a Criteria object containing the primary key for this object.
891: *
892: * Unlike buildCriteria() this method includes the primary key values regardless
893: * of whether or not they have been modified.
894: *
895: * @return Criteria The Criteria object containing value(s) for primary key(s).
896: */
897: public function buildPkeyCriteria()
898: {
899: $criteria = new Criteria(FeatureDbxrefPeer::DATABASE_NAME);
900: $criteria->add(FeatureDbxrefPeer::FEATURE_DBXREF_ID, $this->feature_dbxref_id);
901:
902: return $criteria;
903: }
904:
905: /**
906: * Returns the primary key for this object (row).
907: * @return int
908: */
909: public function getPrimaryKey()
910: {
911: return $this->getFeatureDbxrefId();
912: }
913:
914: /**
915: * Generic method to set the primary key (feature_dbxref_id column).
916: *
917: * @param int $key Primary key.
918: * @return void
919: */
920: public function setPrimaryKey($key)
921: {
922: $this->setFeatureDbxrefId($key);
923: }
924:
925: /**
926: * Returns true if the primary key for this object is null.
927: * @return boolean
928: */
929: public function isPrimaryKeyNull()
930: {
931:
932: return null === $this->getFeatureDbxrefId();
933: }
934:
935: /**
936: * Sets contents of passed object to values from current object.
937: *
938: * If desired, this method can also make copies of all associated (fkey referrers)
939: * objects.
940: *
941: * @param object $copyObj An object of FeatureDbxref (or compatible) type.
942: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
943: * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
944: * @throws PropelException
945: */
946: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
947: {
948: $copyObj->setFeatureId($this->getFeatureId());
949: $copyObj->setDbxrefId($this->getDbxrefId());
950: $copyObj->setIsCurrent($this->getIsCurrent());
951:
952: if ($deepCopy && !$this->startCopy) {
953: // important: temporarily setNew(false) because this affects the behavior of
954: // the getter/setter methods for fkey referrer objects.
955: $copyObj->setNew(false);
956: // store object hash to prevent cycle
957: $this->startCopy = true;
958:
959: //unflag object copy
960: $this->startCopy = false;
961: } // if ($deepCopy)
962:
963: if ($makeNew) {
964: $copyObj->setNew(true);
965: $copyObj->setFeatureDbxrefId(NULL); // this is a auto-increment column, so set to default value
966: }
967: }
968:
969: /**
970: * Makes a copy of this object that will be inserted as a new row in table when saved.
971: * It creates a new object filling in the simple attributes, but skipping any primary
972: * keys that are defined for the table.
973: *
974: * If desired, this method can also make copies of all associated (fkey referrers)
975: * objects.
976: *
977: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
978: * @return FeatureDbxref Clone of current object.
979: * @throws PropelException
980: */
981: public function copy($deepCopy = false)
982: {
983: // we use get_class(), because this might be a subclass
984: $clazz = get_class($this);
985: $copyObj = new $clazz();
986: $this->copyInto($copyObj, $deepCopy);
987:
988: return $copyObj;
989: }
990:
991: /**
992: * Returns a peer instance associated with this om.
993: *
994: * Since Peer classes are not to have any instance attributes, this method returns the
995: * same instance for all member of this class. The method could therefore
996: * be static, but this would prevent one from overriding the behavior.
997: *
998: * @return FeatureDbxrefPeer
999: */
1000: public function getPeer()
1001: {
1002: if (self::$peer === null) {
1003: self::$peer = new FeatureDbxrefPeer();
1004: }
1005:
1006: return self::$peer;
1007: }
1008:
1009: /**
1010: * Declares an association between this object and a Dbxref object.
1011: *
1012: * @param Dbxref $v
1013: * @return FeatureDbxref The current object (for fluent API support)
1014: * @throws PropelException
1015: */
1016: public function setDbxref(Dbxref $v = null)
1017: {
1018: if ($v === null) {
1019: $this->setDbxrefId(NULL);
1020: } else {
1021: $this->setDbxrefId($v->getDbxrefId());
1022: }
1023:
1024: $this->aDbxref = $v;
1025:
1026: // Add binding for other direction of this n:n relationship.
1027: // If this object has already been added to the Dbxref object, it will not be re-added.
1028: if ($v !== null) {
1029: $v->addFeatureDbxref($this);
1030: }
1031:
1032:
1033: return $this;
1034: }
1035:
1036:
1037: /**
1038: * Get the associated Dbxref object
1039: *
1040: * @param PropelPDO $con Optional Connection object.
1041: * @param $doQuery Executes a query to get the object if required
1042: * @return Dbxref The associated Dbxref object.
1043: * @throws PropelException
1044: */
1045: public function getDbxref(PropelPDO $con = null, $doQuery = true)
1046: {
1047: if ($this->aDbxref === null && ($this->dbxref_id !== null) && $doQuery) {
1048: $this->aDbxref = DbxrefQuery::create()->findPk($this->dbxref_id, $con);
1049: /* The following can be used additionally to
1050: guarantee the related object contains a reference
1051: to this object. This level of coupling may, however, be
1052: undesirable since it could result in an only partially populated collection
1053: in the referenced object.
1054: $this->aDbxref->addFeatureDbxrefs($this);
1055: */
1056: }
1057:
1058: return $this->aDbxref;
1059: }
1060:
1061: /**
1062: * Declares an association between this object and a Feature object.
1063: *
1064: * @param Feature $v
1065: * @return FeatureDbxref The current object (for fluent API support)
1066: * @throws PropelException
1067: */
1068: public function setFeature(Feature $v = null)
1069: {
1070: if ($v === null) {
1071: $this->setFeatureId(NULL);
1072: } else {
1073: $this->setFeatureId($v->getFeatureId());
1074: }
1075:
1076: $this->aFeature = $v;
1077:
1078: // Add binding for other direction of this n:n relationship.
1079: // If this object has already been added to the Feature object, it will not be re-added.
1080: if ($v !== null) {
1081: $v->addFeatureDbxref($this);
1082: }
1083:
1084:
1085: return $this;
1086: }
1087:
1088:
1089: /**
1090: * Get the associated Feature object
1091: *
1092: * @param PropelPDO $con Optional Connection object.
1093: * @param $doQuery Executes a query to get the object if required
1094: * @return Feature The associated Feature object.
1095: * @throws PropelException
1096: */
1097: public function getFeature(PropelPDO $con = null, $doQuery = true)
1098: {
1099: if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) {
1100: $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con);
1101: /* The following can be used additionally to
1102: guarantee the related object contains a reference
1103: to this object. This level of coupling may, however, be
1104: undesirable since it could result in an only partially populated collection
1105: in the referenced object.
1106: $this->aFeature->addFeatureDbxrefs($this);
1107: */
1108: }
1109:
1110: return $this->aFeature;
1111: }
1112:
1113: /**
1114: * Clears the current object and sets all attributes to their default values
1115: */
1116: public function clear()
1117: {
1118: $this->feature_dbxref_id = null;
1119: $this->feature_id = null;
1120: $this->dbxref_id = null;
1121: $this->is_current = null;
1122: $this->alreadyInSave = false;
1123: $this->alreadyInValidation = false;
1124: $this->alreadyInClearAllReferencesDeep = false;
1125: $this->clearAllReferences();
1126: $this->applyDefaultValues();
1127: $this->resetModified();
1128: $this->setNew(true);
1129: $this->setDeleted(false);
1130: }
1131:
1132: /**
1133: * Resets all references to other model objects or collections of model objects.
1134: *
1135: * This method is a user-space workaround for PHP's inability to garbage collect
1136: * objects with circular references (even in PHP 5.3). This is currently necessary
1137: * when using Propel in certain daemon or large-volumne/high-memory operations.
1138: *
1139: * @param boolean $deep Whether to also clear the references on all referrer objects.
1140: */
1141: public function clearAllReferences($deep = false)
1142: {
1143: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
1144: $this->alreadyInClearAllReferencesDeep = true;
1145: if ($this->aDbxref instanceof Persistent) {
1146: $this->aDbxref->clearAllReferences($deep);
1147: }
1148: if ($this->aFeature instanceof Persistent) {
1149: $this->aFeature->clearAllReferences($deep);
1150: }
1151:
1152: $this->alreadyInClearAllReferencesDeep = false;
1153: } // if ($deep)
1154:
1155: $this->aDbxref = null;
1156: $this->aFeature = null;
1157: }
1158:
1159: /**
1160: * return the string representation of this object
1161: *
1162: * @return string
1163: */
1164: public function __toString()
1165: {
1166: return (string) $this->exportTo(FeatureDbxrefPeer::DEFAULT_STRING_FORMAT);
1167: }
1168:
1169: /**
1170: * return true is the object is in saving state
1171: *
1172: * @return boolean
1173: */
1174: public function isAlreadyInSave()
1175: {
1176: return $this->alreadyInSave;
1177: }
1178:
1179: }
1180: