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