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