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