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