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