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\Product;
17: use Thelia\Model\ProductQuery;
18: use Thelia\Model\ProductVersion;
19: use Thelia\Model\ProductVersionPeer;
20: use Thelia\Model\ProductVersionQuery;
21:
22: 23: 24: 25: 26: 27: 28:
29: abstract class BaseProductVersion extends BaseObject implements Persistent
30: {
31: 32: 33:
34: const PEER = 'Thelia\\Model\\ProductVersionPeer';
35:
36: 37: 38: 39: 40: 41:
42: protected static $peer;
43:
44: 45: 46: 47:
48: protected $startCopy = false;
49:
50: 51: 52: 53:
54: protected $id;
55:
56: 57: 58: 59:
60: protected $tax_rule_id;
61:
62: 63: 64: 65:
66: protected $ref;
67:
68: 69: 70: 71:
72: protected $price;
73:
74: 75: 76: 77:
78: protected $price2;
79:
80: 81: 82: 83:
84: protected $ecotax;
85:
86: 87: 88: 89: 90:
91: protected $newness;
92:
93: 94: 95: 96: 97:
98: protected $promo;
99:
100: 101: 102: 103: 104:
105: protected $stock;
106:
107: 108: 109: 110: 111:
112: protected $visible;
113:
114: 115: 116: 117:
118: protected $weight;
119:
120: 121: 122: 123:
124: protected $position;
125:
126: 127: 128: 129:
130: protected $created_at;
131:
132: 133: 134: 135:
136: protected $updated_at;
137:
138: 139: 140: 141: 142:
143: protected $version;
144:
145: 146: 147: 148:
149: protected $version_created_at;
150:
151: 152: 153: 154:
155: protected $version_created_by;
156:
157: 158: 159:
160: protected $aProduct;
161:
162: 163: 164: 165: 166:
167: protected $alreadyInSave = false;
168:
169: 170: 171: 172: 173:
174: protected $alreadyInValidation = false;
175:
176: 177: 178: 179: 180: 181:
182: public function applyDefaultValues()
183: {
184: $this->newness = 0;
185: $this->promo = 0;
186: $this->stock = 0;
187: $this->visible = 0;
188: $this->version = 0;
189: }
190:
191: 192: 193: 194:
195: public function __construct()
196: {
197: parent::__construct();
198: $this->applyDefaultValues();
199: }
200:
201: 202: 203: 204: 205:
206: public function getId()
207: {
208: return $this->id;
209: }
210:
211: 212: 213: 214: 215:
216: public function getTaxRuleId()
217: {
218: return $this->tax_rule_id;
219: }
220:
221: 222: 223: 224: 225:
226: public function getRef()
227: {
228: return $this->ref;
229: }
230:
231: 232: 233: 234: 235:
236: public function getPrice()
237: {
238: return $this->price;
239: }
240:
241: 242: 243: 244: 245:
246: public function getPrice2()
247: {
248: return $this->price2;
249: }
250:
251: 252: 253: 254: 255:
256: public function getEcotax()
257: {
258: return $this->ecotax;
259: }
260:
261: 262: 263: 264: 265:
266: public function getNewness()
267: {
268: return $this->newness;
269: }
270:
271: 272: 273: 274: 275:
276: public function getPromo()
277: {
278: return $this->promo;
279: }
280:
281: 282: 283: 284: 285:
286: public function getStock()
287: {
288: return $this->stock;
289: }
290:
291: 292: 293: 294: 295:
296: public function getVisible()
297: {
298: return $this->visible;
299: }
300:
301: 302: 303: 304: 305:
306: public function getWeight()
307: {
308: return $this->weight;
309: }
310:
311: 312: 313: 314: 315:
316: public function getPosition()
317: {
318: return $this->position;
319: }
320:
321: 322: 323: 324: 325: 326: 327: 328: 329:
330: public function getCreatedAt($format = 'Y-m-d H:i:s')
331: {
332: if ($this->created_at === null) {
333: return null;
334: }
335:
336: if ($this->created_at === '0000-00-00 00:00:00') {
337:
338:
339: return null;
340: } else {
341: try {
342: $dt = new DateTime($this->created_at);
343: } catch (Exception $x) {
344: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
345: }
346: }
347:
348: if ($format === null) {
349:
350: return $dt;
351: } elseif (strpos($format, '%') !== false) {
352: return strftime($format, $dt->format('U'));
353: } else {
354: return $dt->format($format);
355: }
356: }
357:
358: 359: 360: 361: 362: 363: 364: 365: 366:
367: public function getUpdatedAt($format = 'Y-m-d H:i:s')
368: {
369: if ($this->updated_at === null) {
370: return null;
371: }
372:
373: if ($this->updated_at === '0000-00-00 00:00:00') {
374:
375:
376: return null;
377: } else {
378: try {
379: $dt = new DateTime($this->updated_at);
380: } catch (Exception $x) {
381: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
382: }
383: }
384:
385: if ($format === null) {
386:
387: return $dt;
388: } elseif (strpos($format, '%') !== false) {
389: return strftime($format, $dt->format('U'));
390: } else {
391: return $dt->format($format);
392: }
393: }
394:
395: 396: 397: 398: 399:
400: public function getVersion()
401: {
402: return $this->version;
403: }
404:
405: 406: 407: 408: 409: 410: 411: 412: 413:
414: public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
415: {
416: if ($this->version_created_at === null) {
417: return null;
418: }
419:
420: if ($this->version_created_at === '0000-00-00 00:00:00') {
421:
422:
423: return null;
424: } else {
425: try {
426: $dt = new DateTime($this->version_created_at);
427: } catch (Exception $x) {
428: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
429: }
430: }
431:
432: if ($format === null) {
433:
434: return $dt;
435: } elseif (strpos($format, '%') !== false) {
436: return strftime($format, $dt->format('U'));
437: } else {
438: return $dt->format($format);
439: }
440: }
441:
442: 443: 444: 445: 446:
447: public function getVersionCreatedBy()
448: {
449: return $this->version_created_by;
450: }
451:
452: 453: 454: 455: 456: 457:
458: public function setId($v)
459: {
460: if ($v !== null) {
461: $v = (int) $v;
462: }
463:
464: if ($this->id !== $v) {
465: $this->id = $v;
466: $this->modifiedColumns[] = ProductVersionPeer::ID;
467: }
468:
469: if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
470: $this->aProduct = null;
471: }
472:
473:
474: return $this;
475: }
476:
477: 478: 479: 480: 481: 482:
483: public function setTaxRuleId($v)
484: {
485: if ($v !== null) {
486: $v = (int) $v;
487: }
488:
489: if ($this->tax_rule_id !== $v) {
490: $this->tax_rule_id = $v;
491: $this->modifiedColumns[] = ProductVersionPeer::TAX_RULE_ID;
492: }
493:
494:
495: return $this;
496: }
497:
498: 499: 500: 501: 502: 503:
504: public function setRef($v)
505: {
506: if ($v !== null) {
507: $v = (string) $v;
508: }
509:
510: if ($this->ref !== $v) {
511: $this->ref = $v;
512: $this->modifiedColumns[] = ProductVersionPeer::REF;
513: }
514:
515:
516: return $this;
517: }
518:
519: 520: 521: 522: 523: 524:
525: public function setPrice($v)
526: {
527: if ($v !== null) {
528: $v = (double) $v;
529: }
530:
531: if ($this->price !== $v) {
532: $this->price = $v;
533: $this->modifiedColumns[] = ProductVersionPeer::PRICE;
534: }
535:
536:
537: return $this;
538: }
539:
540: 541: 542: 543: 544: 545:
546: public function setPrice2($v)
547: {
548: if ($v !== null) {
549: $v = (double) $v;
550: }
551:
552: if ($this->price2 !== $v) {
553: $this->price2 = $v;
554: $this->modifiedColumns[] = ProductVersionPeer::PRICE2;
555: }
556:
557:
558: return $this;
559: }
560:
561: 562: 563: 564: 565: 566:
567: public function setEcotax($v)
568: {
569: if ($v !== null) {
570: $v = (double) $v;
571: }
572:
573: if ($this->ecotax !== $v) {
574: $this->ecotax = $v;
575: $this->modifiedColumns[] = ProductVersionPeer::ECOTAX;
576: }
577:
578:
579: return $this;
580: }
581:
582: 583: 584: 585: 586: 587:
588: public function setNewness($v)
589: {
590: if ($v !== null) {
591: $v = (int) $v;
592: }
593:
594: if ($this->newness !== $v) {
595: $this->newness = $v;
596: $this->modifiedColumns[] = ProductVersionPeer::NEWNESS;
597: }
598:
599:
600: return $this;
601: }
602:
603: 604: 605: 606: 607: 608:
609: public function setPromo($v)
610: {
611: if ($v !== null) {
612: $v = (int) $v;
613: }
614:
615: if ($this->promo !== $v) {
616: $this->promo = $v;
617: $this->modifiedColumns[] = ProductVersionPeer::PROMO;
618: }
619:
620:
621: return $this;
622: }
623:
624: 625: 626: 627: 628: 629:
630: public function setStock($v)
631: {
632: if ($v !== null) {
633: $v = (int) $v;
634: }
635:
636: if ($this->stock !== $v) {
637: $this->stock = $v;
638: $this->modifiedColumns[] = ProductVersionPeer::STOCK;
639: }
640:
641:
642: return $this;
643: }
644:
645: 646: 647: 648: 649: 650:
651: public function setVisible($v)
652: {
653: if ($v !== null) {
654: $v = (int) $v;
655: }
656:
657: if ($this->visible !== $v) {
658: $this->visible = $v;
659: $this->modifiedColumns[] = ProductVersionPeer::VISIBLE;
660: }
661:
662:
663: return $this;
664: }
665:
666: 667: 668: 669: 670: 671:
672: public function setWeight($v)
673: {
674: if ($v !== null) {
675: $v = (double) $v;
676: }
677:
678: if ($this->weight !== $v) {
679: $this->weight = $v;
680: $this->modifiedColumns[] = ProductVersionPeer::WEIGHT;
681: }
682:
683:
684: return $this;
685: }
686:
687: 688: 689: 690: 691: 692:
693: public function setPosition($v)
694: {
695: if ($v !== null) {
696: $v = (int) $v;
697: }
698:
699: if ($this->position !== $v) {
700: $this->position = $v;
701: $this->modifiedColumns[] = ProductVersionPeer::POSITION;
702: }
703:
704:
705: return $this;
706: }
707:
708: 709: 710: 711: 712: 713: 714:
715: public function setCreatedAt($v)
716: {
717: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
718: if ($this->created_at !== null || $dt !== null) {
719: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
720: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
721: if ($currentDateAsString !== $newDateAsString) {
722: $this->created_at = $newDateAsString;
723: $this->modifiedColumns[] = ProductVersionPeer::CREATED_AT;
724: }
725: }
726:
727:
728: return $this;
729: }
730:
731: 732: 733: 734: 735: 736: 737:
738: public function setUpdatedAt($v)
739: {
740: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
741: if ($this->updated_at !== null || $dt !== null) {
742: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
743: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
744: if ($currentDateAsString !== $newDateAsString) {
745: $this->updated_at = $newDateAsString;
746: $this->modifiedColumns[] = ProductVersionPeer::UPDATED_AT;
747: }
748: }
749:
750:
751: return $this;
752: }
753:
754: 755: 756: 757: 758: 759:
760: public function setVersion($v)
761: {
762: if ($v !== null) {
763: $v = (int) $v;
764: }
765:
766: if ($this->version !== $v) {
767: $this->version = $v;
768: $this->modifiedColumns[] = ProductVersionPeer::VERSION;
769: }
770:
771:
772: return $this;
773: }
774:
775: 776: 777: 778: 779: 780: 781:
782: public function setVersionCreatedAt($v)
783: {
784: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
785: if ($this->version_created_at !== null || $dt !== null) {
786: $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
787: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
788: if ($currentDateAsString !== $newDateAsString) {
789: $this->version_created_at = $newDateAsString;
790: $this->modifiedColumns[] = ProductVersionPeer::VERSION_CREATED_AT;
791: }
792: }
793:
794:
795: return $this;
796: }
797:
798: 799: 800: 801: 802: 803:
804: public function setVersionCreatedBy($v)
805: {
806: if ($v !== null) {
807: $v = (string) $v;
808: }
809:
810: if ($this->version_created_by !== $v) {
811: $this->version_created_by = $v;
812: $this->modifiedColumns[] = ProductVersionPeer::VERSION_CREATED_BY;
813: }
814:
815:
816: return $this;
817: }
818:
819: 820: 821: 822: 823: 824: 825: 826:
827: public function hasOnlyDefaultValues()
828: {
829: if ($this->newness !== 0) {
830: return false;
831: }
832:
833: if ($this->promo !== 0) {
834: return false;
835: }
836:
837: if ($this->stock !== 0) {
838: return false;
839: }
840:
841: if ($this->visible !== 0) {
842: return false;
843: }
844:
845: if ($this->version !== 0) {
846: return false;
847: }
848:
849:
850: return true;
851: }
852:
853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866:
867: public function hydrate($row, $startcol = 0, $rehydrate = false)
868: {
869: try {
870:
871: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
872: $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
873: $this->ref = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
874: $this->price = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
875: $this->price2 = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
876: $this->ecotax = ($row[$startcol + 5] !== null) ? (double) $row[$startcol + 5] : null;
877: $this->newness = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
878: $this->promo = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
879: $this->stock = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
880: $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
881: $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null;
882: $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
883: $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
884: $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
885: $this->version = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
886: $this->version_created_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
887: $this->version_created_by = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
888: $this->resetModified();
889:
890: $this->setNew(false);
891:
892: if ($rehydrate) {
893: $this->ensureConsistency();
894: }
895:
896: return $startcol + 17;
897:
898: } catch (Exception $e) {
899: throw new PropelException("Error populating ProductVersion object", $e);
900: }
901: }
902:
903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915:
916: public function ensureConsistency()
917: {
918:
919: if ($this->aProduct !== null && $this->id !== $this->aProduct->getId()) {
920: $this->aProduct = null;
921: }
922: }
923:
924: 925: 926: 927: 928: 929: 930: 931: 932: 933:
934: public function reload($deep = false, PropelPDO $con = null)
935: {
936: if ($this->isDeleted()) {
937: throw new PropelException("Cannot reload a deleted object.");
938: }
939:
940: if ($this->isNew()) {
941: throw new PropelException("Cannot reload an unsaved object.");
942: }
943:
944: if ($con === null) {
945: $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
946: }
947:
948:
949:
950:
951: $stmt = ProductVersionPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
952: $row = $stmt->fetch(PDO::FETCH_NUM);
953: $stmt->closeCursor();
954: if (!$row) {
955: throw new PropelException('Cannot find matching row in the database to reload object values.');
956: }
957: $this->hydrate($row, 0, true);
958:
959: if ($deep) {
960:
961: $this->aProduct = null;
962: }
963: }
964:
965: 966: 967: 968: 969: 970: 971: 972: 973: 974:
975: public function delete(PropelPDO $con = null)
976: {
977: if ($this->isDeleted()) {
978: throw new PropelException("This object has already been deleted.");
979: }
980:
981: if ($con === null) {
982: $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
983: }
984:
985: $con->beginTransaction();
986: try {
987: $deleteQuery = ProductVersionQuery::create()
988: ->filterByPrimaryKey($this->getPrimaryKey());
989: $ret = $this->preDelete($con);
990: if ($ret) {
991: $deleteQuery->delete($con);
992: $this->postDelete($con);
993: $con->commit();
994: $this->setDeleted(true);
995: } else {
996: $con->commit();
997: }
998: } catch (Exception $e) {
999: $con->rollBack();
1000: throw $e;
1001: }
1002: }
1003:
1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017:
1018: public function save(PropelPDO $con = null)
1019: {
1020: if ($this->isDeleted()) {
1021: throw new PropelException("You cannot save an object that has been deleted.");
1022: }
1023:
1024: if ($con === null) {
1025: $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1026: }
1027:
1028: $con->beginTransaction();
1029: $isInsert = $this->isNew();
1030: try {
1031: $ret = $this->preSave($con);
1032: if ($isInsert) {
1033: $ret = $ret && $this->preInsert($con);
1034: } else {
1035: $ret = $ret && $this->preUpdate($con);
1036: }
1037: if ($ret) {
1038: $affectedRows = $this->doSave($con);
1039: if ($isInsert) {
1040: $this->postInsert($con);
1041: } else {
1042: $this->postUpdate($con);
1043: }
1044: $this->postSave($con);
1045: ProductVersionPeer::addInstanceToPool($this);
1046: } else {
1047: $affectedRows = 0;
1048: }
1049: $con->commit();
1050:
1051: return $affectedRows;
1052: } catch (Exception $e) {
1053: $con->rollBack();
1054: throw $e;
1055: }
1056: }
1057:
1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068:
1069: protected function doSave(PropelPDO $con)
1070: {
1071: $affectedRows = 0;
1072: if (!$this->alreadyInSave) {
1073: $this->alreadyInSave = true;
1074:
1075:
1076:
1077:
1078:
1079:
1080: if ($this->aProduct !== null) {
1081: if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
1082: $affectedRows += $this->aProduct->save($con);
1083: }
1084: $this->setProduct($this->aProduct);
1085: }
1086:
1087: if ($this->isNew() || $this->isModified()) {
1088:
1089: if ($this->isNew()) {
1090: $this->doInsert($con);
1091: } else {
1092: $this->doUpdate($con);
1093: }
1094: $affectedRows += 1;
1095: $this->resetModified();
1096: }
1097:
1098: $this->alreadyInSave = false;
1099:
1100: }
1101:
1102: return $affectedRows;
1103: }
1104:
1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112:
1113: protected function doInsert(PropelPDO $con)
1114: {
1115: $modifiedColumns = array();
1116: $index = 0;
1117:
1118:
1119:
1120: if ($this->isColumnModified(ProductVersionPeer::ID)) {
1121: $modifiedColumns[':p' . $index++] = '`ID`';
1122: }
1123: if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) {
1124: $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
1125: }
1126: if ($this->isColumnModified(ProductVersionPeer::REF)) {
1127: $modifiedColumns[':p' . $index++] = '`REF`';
1128: }
1129: if ($this->isColumnModified(ProductVersionPeer::PRICE)) {
1130: $modifiedColumns[':p' . $index++] = '`PRICE`';
1131: }
1132: if ($this->isColumnModified(ProductVersionPeer::PRICE2)) {
1133: $modifiedColumns[':p' . $index++] = '`PRICE2`';
1134: }
1135: if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) {
1136: $modifiedColumns[':p' . $index++] = '`ECOTAX`';
1137: }
1138: if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) {
1139: $modifiedColumns[':p' . $index++] = '`NEWNESS`';
1140: }
1141: if ($this->isColumnModified(ProductVersionPeer::PROMO)) {
1142: $modifiedColumns[':p' . $index++] = '`PROMO`';
1143: }
1144: if ($this->isColumnModified(ProductVersionPeer::STOCK)) {
1145: $modifiedColumns[':p' . $index++] = '`STOCK`';
1146: }
1147: if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) {
1148: $modifiedColumns[':p' . $index++] = '`VISIBLE`';
1149: }
1150: if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) {
1151: $modifiedColumns[':p' . $index++] = '`WEIGHT`';
1152: }
1153: if ($this->isColumnModified(ProductVersionPeer::POSITION)) {
1154: $modifiedColumns[':p' . $index++] = '`POSITION`';
1155: }
1156: if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) {
1157: $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
1158: }
1159: if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) {
1160: $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
1161: }
1162: if ($this->isColumnModified(ProductVersionPeer::VERSION)) {
1163: $modifiedColumns[':p' . $index++] = '`VERSION`';
1164: }
1165: if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) {
1166: $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
1167: }
1168: if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) {
1169: $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
1170: }
1171:
1172: $sql = sprintf(
1173: 'INSERT INTO `product_version` (%s) VALUES (%s)',
1174: implode(', ', $modifiedColumns),
1175: implode(', ', array_keys($modifiedColumns))
1176: );
1177:
1178: try {
1179: $stmt = $con->prepare($sql);
1180: foreach ($modifiedColumns as $identifier => $columnName) {
1181: switch ($columnName) {
1182: case '`ID`':
1183: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1184: break;
1185: case '`TAX_RULE_ID`':
1186: $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
1187: break;
1188: case '`REF`':
1189: $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
1190: break;
1191: case '`PRICE`':
1192: $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
1193: break;
1194: case '`PRICE2`':
1195: $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR);
1196: break;
1197: case '`ECOTAX`':
1198: $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR);
1199: break;
1200: case '`NEWNESS`':
1201: $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT);
1202: break;
1203: case '`PROMO`':
1204: $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT);
1205: break;
1206: case '`STOCK`':
1207: $stmt->bindValue($identifier, $this->stock, PDO::PARAM_INT);
1208: break;
1209: case '`VISIBLE`':
1210: $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1211: break;
1212: case '`WEIGHT`':
1213: $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
1214: break;
1215: case '`POSITION`':
1216: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1217: break;
1218: case '`CREATED_AT`':
1219: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1220: break;
1221: case '`UPDATED_AT`':
1222: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1223: break;
1224: case '`VERSION`':
1225: $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1226: break;
1227: case '`VERSION_CREATED_AT`':
1228: $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1229: break;
1230: case '`VERSION_CREATED_BY`':
1231: $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1232: break;
1233: }
1234: }
1235: $stmt->execute();
1236: } catch (Exception $e) {
1237: Propel::log($e->getMessage(), Propel::LOG_ERR);
1238: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1239: }
1240:
1241: $this->setNew(false);
1242: }
1243:
1244: 1245: 1246: 1247: 1248: 1249: 1250:
1251: protected function doUpdate(PropelPDO $con)
1252: {
1253: $selectCriteria = $this->buildPkeyCriteria();
1254: $valuesCriteria = $this->buildCriteria();
1255: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1256: }
1257:
1258: 1259: 1260: 1261:
1262: protected $validationFailures = array();
1263:
1264: 1265: 1266: 1267: 1268: 1269: 1270:
1271: public function getValidationFailures()
1272: {
1273: return $this->validationFailures;
1274: }
1275:
1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286:
1287: public function validate($columns = null)
1288: {
1289: $res = $this->doValidate($columns);
1290: if ($res === true) {
1291: $this->validationFailures = array();
1292:
1293: return true;
1294: } else {
1295: $this->validationFailures = $res;
1296:
1297: return false;
1298: }
1299: }
1300:
1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310:
1311: protected function doValidate($columns = null)
1312: {
1313: if (!$this->alreadyInValidation) {
1314: $this->alreadyInValidation = true;
1315: $retval = null;
1316:
1317: $failureMap = array();
1318:
1319:
1320:
1321:
1322:
1323:
1324:
1325: if ($this->aProduct !== null) {
1326: if (!$this->aProduct->validate($columns)) {
1327: $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
1328: }
1329: }
1330:
1331:
1332: if (($retval = ProductVersionPeer::doValidate($this, $columns)) !== true) {
1333: $failureMap = array_merge($failureMap, $retval);
1334: }
1335:
1336:
1337:
1338: $this->alreadyInValidation = false;
1339: }
1340:
1341: return (!empty($failureMap) ? $failureMap : true);
1342: }
1343:
1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353:
1354: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1355: {
1356: $pos = ProductVersionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1357: $field = $this->getByPosition($pos);
1358:
1359: return $field;
1360: }
1361:
1362: 1363: 1364: 1365: 1366: 1367: 1368:
1369: public function getByPosition($pos)
1370: {
1371: switch ($pos) {
1372: case 0:
1373: return $this->getId();
1374: break;
1375: case 1:
1376: return $this->getTaxRuleId();
1377: break;
1378: case 2:
1379: return $this->getRef();
1380: break;
1381: case 3:
1382: return $this->getPrice();
1383: break;
1384: case 4:
1385: return $this->getPrice2();
1386: break;
1387: case 5:
1388: return $this->getEcotax();
1389: break;
1390: case 6:
1391: return $this->getNewness();
1392: break;
1393: case 7:
1394: return $this->getPromo();
1395: break;
1396: case 8:
1397: return $this->getStock();
1398: break;
1399: case 9:
1400: return $this->getVisible();
1401: break;
1402: case 10:
1403: return $this->getWeight();
1404: break;
1405: case 11:
1406: return $this->getPosition();
1407: break;
1408: case 12:
1409: return $this->getCreatedAt();
1410: break;
1411: case 13:
1412: return $this->getUpdatedAt();
1413: break;
1414: case 14:
1415: return $this->getVersion();
1416: break;
1417: case 15:
1418: return $this->getVersionCreatedAt();
1419: break;
1420: case 16:
1421: return $this->getVersionCreatedBy();
1422: break;
1423: default:
1424: return null;
1425: break;
1426: }
1427: }
1428:
1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443:
1444: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1445: {
1446: if (isset($alreadyDumpedObjects['ProductVersion'][serialize($this->getPrimaryKey())])) {
1447: return '*RECURSION*';
1448: }
1449: $alreadyDumpedObjects['ProductVersion'][serialize($this->getPrimaryKey())] = true;
1450: $keys = ProductVersionPeer::getFieldNames($keyType);
1451: $result = array(
1452: $keys[0] => $this->getId(),
1453: $keys[1] => $this->getTaxRuleId(),
1454: $keys[2] => $this->getRef(),
1455: $keys[3] => $this->getPrice(),
1456: $keys[4] => $this->getPrice2(),
1457: $keys[5] => $this->getEcotax(),
1458: $keys[6] => $this->getNewness(),
1459: $keys[7] => $this->getPromo(),
1460: $keys[8] => $this->getStock(),
1461: $keys[9] => $this->getVisible(),
1462: $keys[10] => $this->getWeight(),
1463: $keys[11] => $this->getPosition(),
1464: $keys[12] => $this->getCreatedAt(),
1465: $keys[13] => $this->getUpdatedAt(),
1466: $keys[14] => $this->getVersion(),
1467: $keys[15] => $this->getVersionCreatedAt(),
1468: $keys[16] => $this->getVersionCreatedBy(),
1469: );
1470: if ($includeForeignObjects) {
1471: if (null !== $this->aProduct) {
1472: $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1473: }
1474: }
1475:
1476: return $result;
1477: }
1478:
1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489:
1490: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1491: {
1492: $pos = ProductVersionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1493:
1494: $this->setByPosition($pos, $value);
1495: }
1496:
1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504:
1505: public function setByPosition($pos, $value)
1506: {
1507: switch ($pos) {
1508: case 0:
1509: $this->setId($value);
1510: break;
1511: case 1:
1512: $this->setTaxRuleId($value);
1513: break;
1514: case 2:
1515: $this->setRef($value);
1516: break;
1517: case 3:
1518: $this->setPrice($value);
1519: break;
1520: case 4:
1521: $this->setPrice2($value);
1522: break;
1523: case 5:
1524: $this->setEcotax($value);
1525: break;
1526: case 6:
1527: $this->setNewness($value);
1528: break;
1529: case 7:
1530: $this->setPromo($value);
1531: break;
1532: case 8:
1533: $this->setStock($value);
1534: break;
1535: case 9:
1536: $this->setVisible($value);
1537: break;
1538: case 10:
1539: $this->setWeight($value);
1540: break;
1541: case 11:
1542: $this->setPosition($value);
1543: break;
1544: case 12:
1545: $this->setCreatedAt($value);
1546: break;
1547: case 13:
1548: $this->setUpdatedAt($value);
1549: break;
1550: case 14:
1551: $this->setVersion($value);
1552: break;
1553: case 15:
1554: $this->setVersionCreatedAt($value);
1555: break;
1556: case 16:
1557: $this->setVersionCreatedBy($value);
1558: break;
1559: }
1560: }
1561:
1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578:
1579: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1580: {
1581: $keys = ProductVersionPeer::getFieldNames($keyType);
1582:
1583: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
1584: if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
1585: if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
1586: if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
1587: if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]);
1588: if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]);
1589: if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]);
1590: if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]);
1591: if (array_key_exists($keys[8], $arr)) $this->setStock($arr[$keys[8]]);
1592: if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
1593: if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
1594: if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
1595: if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
1596: if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
1597: if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
1598: if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
1599: if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
1600: }
1601:
1602: 1603: 1604: 1605: 1606:
1607: public function buildCriteria()
1608: {
1609: $criteria = new Criteria(ProductVersionPeer::DATABASE_NAME);
1610:
1611: if ($this->isColumnModified(ProductVersionPeer::ID)) $criteria->add(ProductVersionPeer::ID, $this->id);
1612: if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) $criteria->add(ProductVersionPeer::TAX_RULE_ID, $this->tax_rule_id);
1613: if ($this->isColumnModified(ProductVersionPeer::REF)) $criteria->add(ProductVersionPeer::REF, $this->ref);
1614: if ($this->isColumnModified(ProductVersionPeer::PRICE)) $criteria->add(ProductVersionPeer::PRICE, $this->price);
1615: if ($this->isColumnModified(ProductVersionPeer::PRICE2)) $criteria->add(ProductVersionPeer::PRICE2, $this->price2);
1616: if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) $criteria->add(ProductVersionPeer::ECOTAX, $this->ecotax);
1617: if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) $criteria->add(ProductVersionPeer::NEWNESS, $this->newness);
1618: if ($this->isColumnModified(ProductVersionPeer::PROMO)) $criteria->add(ProductVersionPeer::PROMO, $this->promo);
1619: if ($this->isColumnModified(ProductVersionPeer::STOCK)) $criteria->add(ProductVersionPeer::STOCK, $this->stock);
1620: if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) $criteria->add(ProductVersionPeer::VISIBLE, $this->visible);
1621: if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) $criteria->add(ProductVersionPeer::WEIGHT, $this->weight);
1622: if ($this->isColumnModified(ProductVersionPeer::POSITION)) $criteria->add(ProductVersionPeer::POSITION, $this->position);
1623: if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) $criteria->add(ProductVersionPeer::CREATED_AT, $this->created_at);
1624: if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) $criteria->add(ProductVersionPeer::UPDATED_AT, $this->updated_at);
1625: if ($this->isColumnModified(ProductVersionPeer::VERSION)) $criteria->add(ProductVersionPeer::VERSION, $this->version);
1626: if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) $criteria->add(ProductVersionPeer::VERSION_CREATED_AT, $this->version_created_at);
1627: if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) $criteria->add(ProductVersionPeer::VERSION_CREATED_BY, $this->version_created_by);
1628:
1629: return $criteria;
1630: }
1631:
1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639:
1640: public function buildPkeyCriteria()
1641: {
1642: $criteria = new Criteria(ProductVersionPeer::DATABASE_NAME);
1643: $criteria->add(ProductVersionPeer::ID, $this->id);
1644: $criteria->add(ProductVersionPeer::VERSION, $this->version);
1645:
1646: return $criteria;
1647: }
1648:
1649: 1650: 1651: 1652: 1653:
1654: public function getPrimaryKey()
1655: {
1656: $pks = array();
1657: $pks[0] = $this->getId();
1658: $pks[1] = $this->getVersion();
1659:
1660: return $pks;
1661: }
1662:
1663: 1664: 1665: 1666: 1667: 1668:
1669: public function setPrimaryKey($keys)
1670: {
1671: $this->setId($keys[0]);
1672: $this->setVersion($keys[1]);
1673: }
1674:
1675: 1676: 1677: 1678:
1679: public function isPrimaryKeyNull()
1680: {
1681:
1682: return (null === $this->getId()) && (null === $this->getVersion());
1683: }
1684:
1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695:
1696: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1697: {
1698: $copyObj->setId($this->getId());
1699: $copyObj->setTaxRuleId($this->getTaxRuleId());
1700: $copyObj->setRef($this->getRef());
1701: $copyObj->setPrice($this->getPrice());
1702: $copyObj->setPrice2($this->getPrice2());
1703: $copyObj->setEcotax($this->getEcotax());
1704: $copyObj->setNewness($this->getNewness());
1705: $copyObj->setPromo($this->getPromo());
1706: $copyObj->setStock($this->getStock());
1707: $copyObj->setVisible($this->getVisible());
1708: $copyObj->setWeight($this->getWeight());
1709: $copyObj->setPosition($this->getPosition());
1710: $copyObj->setCreatedAt($this->getCreatedAt());
1711: $copyObj->setUpdatedAt($this->getUpdatedAt());
1712: $copyObj->setVersion($this->getVersion());
1713: $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
1714: $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
1715:
1716: if ($deepCopy && !$this->startCopy) {
1717:
1718:
1719: $copyObj->setNew(false);
1720:
1721: $this->startCopy = true;
1722:
1723:
1724: $this->startCopy = false;
1725: }
1726:
1727: if ($makeNew) {
1728: $copyObj->setNew(true);
1729: }
1730: }
1731:
1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743:
1744: public function copy($deepCopy = false)
1745: {
1746:
1747: $clazz = get_class($this);
1748: $copyObj = new $clazz();
1749: $this->copyInto($copyObj, $deepCopy);
1750:
1751: return $copyObj;
1752: }
1753:
1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762:
1763: public function getPeer()
1764: {
1765: if (self::$peer === null) {
1766: self::$peer = new ProductVersionPeer();
1767: }
1768:
1769: return self::$peer;
1770: }
1771:
1772: 1773: 1774: 1775: 1776: 1777: 1778:
1779: public function setProduct(Product $v = null)
1780: {
1781: if ($v === null) {
1782: $this->setId(NULL);
1783: } else {
1784: $this->setId($v->getId());
1785: }
1786:
1787: $this->aProduct = $v;
1788:
1789:
1790:
1791: if ($v !== null) {
1792: $v->addProductVersion($this);
1793: }
1794:
1795:
1796: return $this;
1797: }
1798:
1799:
1800: 1801: 1802: 1803: 1804: 1805: 1806:
1807: public function getProduct(PropelPDO $con = null)
1808: {
1809: if ($this->aProduct === null && ($this->id !== null)) {
1810: $this->aProduct = ProductQuery::create()->findPk($this->id, $con);
1811: 1812: 1813: 1814: 1815: 1816: 1817:
1818: }
1819:
1820: return $this->aProduct;
1821: }
1822:
1823: 1824: 1825:
1826: public function clear()
1827: {
1828: $this->id = null;
1829: $this->tax_rule_id = null;
1830: $this->ref = null;
1831: $this->price = null;
1832: $this->price2 = null;
1833: $this->ecotax = null;
1834: $this->newness = null;
1835: $this->promo = null;
1836: $this->stock = null;
1837: $this->visible = null;
1838: $this->weight = null;
1839: $this->position = null;
1840: $this->created_at = null;
1841: $this->updated_at = null;
1842: $this->version = null;
1843: $this->version_created_at = null;
1844: $this->version_created_by = null;
1845: $this->alreadyInSave = false;
1846: $this->alreadyInValidation = false;
1847: $this->clearAllReferences();
1848: $this->applyDefaultValues();
1849: $this->resetModified();
1850: $this->setNew(true);
1851: $this->setDeleted(false);
1852: }
1853:
1854: 1855: 1856: 1857: 1858: 1859: 1860: 1861: 1862:
1863: public function clearAllReferences($deep = false)
1864: {
1865: if ($deep) {
1866: }
1867:
1868: $this->aProduct = null;
1869: }
1870:
1871: 1872: 1873: 1874: 1875:
1876: public function __toString()
1877: {
1878: return (string) $this->exportTo(ProductVersionPeer::DEFAULT_STRING_FORMAT);
1879: }
1880:
1881: 1882: 1883: 1884: 1885:
1886: public function isAlreadyInSave()
1887: {
1888: return $this->alreadyInSave;
1889: }
1890:
1891: }
1892: