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