From 4764118f3a4d7cded059f8cc9053c03b87057c0f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 18 Feb 2013 14:39:45 +0100 Subject: [PATCH] update propel in V.1.6.8 --- composer.json | 2 +- composer.lock | 64 +- .../Thelia/Model/map/AccessoryTableMap.php | 18 +- core/lib/Thelia/Model/map/AddressTableMap.php | 38 +- .../Thelia/Model/map/AdminGroupTableMap.php | 16 +- .../lib/Thelia/Model/map/AdminLogTableMap.php | 22 +- core/lib/Thelia/Model/map/AdminTableMap.php | 24 +- core/lib/Thelia/Model/map/AreaTableMap.php | 16 +- .../Model/map/AttributeAvI18nTableMap.php | 12 +- .../Thelia/Model/map/AttributeAvTableMap.php | 26 +- .../Model/map/AttributeCategoryTableMap.php | 16 +- .../map/AttributeCombinationTableMap.php | 18 +- .../Model/map/AttributeI18nTableMap.php | 12 +- .../Thelia/Model/map/AttributeTableMap.php | 24 +- .../Thelia/Model/map/CategoryI18nTableMap.php | 12 +- .../lib/Thelia/Model/map/CategoryTableMap.php | 47 +- .../Model/map/CategoryVersionTableMap.php | 20 +- .../Thelia/Model/map/CombinationTableMap.php | 14 +- .../Thelia/Model/map/ConfigI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/ConfigTableMap.php | 30 +- .../Thelia/Model/map/ContentAssocTableMap.php | 20 +- .../Model/map/ContentFolderTableMap.php | 14 +- .../Thelia/Model/map/ContentI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/ContentTableMap.php | 43 +- .../Model/map/ContentVersionTableMap.php | 16 +- .../Thelia/Model/map/CountryI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/CountryTableMap.php | 30 +- .../Thelia/Model/map/CouponOrderTableMap.php | 18 +- .../Thelia/Model/map/CouponRuleTableMap.php | 20 +- core/lib/Thelia/Model/map/CouponTableMap.php | 26 +- .../lib/Thelia/Model/map/CurrencyTableMap.php | 22 +- .../lib/Thelia/Model/map/CustomerTableMap.php | 54 +- .../Model/map/CustomerTitleI18nTableMap.php | 8 +- .../Model/map/CustomerTitleTableMap.php | 26 +- .../Thelia/Model/map/DelivzoneTableMap.php | 16 +- .../Thelia/Model/map/DocumentI18nTableMap.php | 12 +- .../lib/Thelia/Model/map/DocumentTableMap.php | 34 +- .../Model/map/FeatureAvI18nTableMap.php | 12 +- .../Thelia/Model/map/FeatureAvTableMap.php | 24 +- .../Model/map/FeatureCategoryTableMap.php | 16 +- .../Thelia/Model/map/FeatureI18nTableMap.php | 12 +- .../Thelia/Model/map/FeatureProdTableMap.php | 22 +- core/lib/Thelia/Model/map/FeatureTableMap.php | 26 +- .../Thelia/Model/map/FolderI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/FolderTableMap.php | 47 +- .../Model/map/FolderVersionTableMap.php | 20 +- .../Thelia/Model/map/GroupI18nTableMap.php | 12 +- .../Thelia/Model/map/GroupModuleTableMap.php | 18 +- .../Model/map/GroupResourceTableMap.php | 20 +- core/lib/Thelia/Model/map/GroupTableMap.php | 24 +- .../Thelia/Model/map/ImageI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/ImageTableMap.php | 34 +- core/lib/Thelia/Model/map/LangTableMap.php | 22 +- .../Thelia/Model/map/MessageI18nTableMap.php | 10 +- core/lib/Thelia/Model/map/MessageTableMap.php | 45 +- .../Model/map/MessageVersionTableMap.php | 18 +- .../Thelia/Model/map/ModuleI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/ModuleTableMap.php | 30 +- .../Thelia/Model/map/OrderAddressTableMap.php | 34 +- .../Thelia/Model/map/OrderFeatureTableMap.php | 18 +- .../Thelia/Model/map/OrderProductTableMap.php | 30 +- .../Model/map/OrderStatusI18nTableMap.php | 12 +- .../Thelia/Model/map/OrderStatusTableMap.php | 24 +- core/lib/Thelia/Model/map/OrderTableMap.php | 42 +- .../Model/map/ProductCategoryTableMap.php | 14 +- .../Thelia/Model/map/ProductI18nTableMap.php | 12 +- core/lib/Thelia/Model/map/ProductTableMap.php | 61 +- .../Model/map/ProductVersionTableMap.php | 34 +- .../Thelia/Model/map/ResourceI18nTableMap.php | 12 +- .../lib/Thelia/Model/map/ResourceTableMap.php | 24 +- .../Thelia/Model/map/RewritingTableMap.php | 22 +- core/lib/Thelia/Model/map/StockTableMap.php | 20 +- core/lib/Thelia/Model/map/TaxI18nTableMap.php | 8 +- .../Model/map/TaxRuleCountryTableMap.php | 20 +- .../Thelia/Model/map/TaxRuleI18nTableMap.php | 4 +- core/lib/Thelia/Model/map/TaxRuleTableMap.php | 28 +- core/lib/Thelia/Model/map/TaxTableMap.php | 24 +- core/lib/Thelia/Model/om/BaseAccessory.php | 116 +-- .../lib/Thelia/Model/om/BaseAccessoryPeer.php | 49 +- .../Thelia/Model/om/BaseAccessoryQuery.php | 61 +- core/lib/Thelia/Model/om/BaseAddress.php | 176 ++-- core/lib/Thelia/Model/om/BaseAddressPeer.php | 109 +-- core/lib/Thelia/Model/om/BaseAddressQuery.php | 61 +- core/lib/Thelia/Model/om/BaseAdmin.php | 167 ++-- core/lib/Thelia/Model/om/BaseAdminGroup.php | 110 ++- .../Thelia/Model/om/BaseAdminGroupPeer.php | 43 +- .../Thelia/Model/om/BaseAdminGroupQuery.php | 58 +- core/lib/Thelia/Model/om/BaseAdminLog.php | 112 +-- core/lib/Thelia/Model/om/BaseAdminLogPeer.php | 61 +- .../lib/Thelia/Model/om/BaseAdminLogQuery.php | 44 +- core/lib/Thelia/Model/om/BaseAdminPeer.php | 67 +- core/lib/Thelia/Model/om/BaseAdminQuery.php | 48 +- core/lib/Thelia/Model/om/BaseArea.php | 192 +++-- core/lib/Thelia/Model/om/BaseAreaPeer.php | 43 +- core/lib/Thelia/Model/om/BaseAreaQuery.php | 55 +- core/lib/Thelia/Model/om/BaseAttribute.php | 302 ++++--- core/lib/Thelia/Model/om/BaseAttributeAv.php | 214 +++-- .../Thelia/Model/om/BaseAttributeAvI18n.php | 72 +- .../Model/om/BaseAttributeAvI18nPeer.php | 49 +- .../Model/om/BaseAttributeAvI18nQuery.php | 33 +- .../Thelia/Model/om/BaseAttributeAvPeer.php | 45 +- .../Thelia/Model/om/BaseAttributeAvQuery.php | 68 +- .../Thelia/Model/om/BaseAttributeCategory.php | 110 ++- .../Model/om/BaseAttributeCategoryPeer.php | 43 +- .../Model/om/BaseAttributeCategoryQuery.php | 58 +- .../Model/om/BaseAttributeCombination.php | 124 +-- .../Model/om/BaseAttributeCombinationPeer.php | 49 +- .../om/BaseAttributeCombinationQuery.php | 104 ++- .../lib/Thelia/Model/om/BaseAttributeI18n.php | 72 +- .../Thelia/Model/om/BaseAttributeI18nPeer.php | 49 +- .../Model/om/BaseAttributeI18nQuery.php | 33 +- .../lib/Thelia/Model/om/BaseAttributePeer.php | 39 +- .../Thelia/Model/om/BaseAttributeQuery.php | 69 +- core/lib/Thelia/Model/om/BaseCategory.php | 606 ++++++++------ core/lib/Thelia/Model/om/BaseCategoryI18n.php | 72 +- .../Thelia/Model/om/BaseCategoryI18nPeer.php | 49 +- .../Thelia/Model/om/BaseCategoryI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseCategoryPeer.php | 75 +- .../lib/Thelia/Model/om/BaseCategoryQuery.php | 98 ++- .../Thelia/Model/om/BaseCategoryVersion.php | 153 ++-- .../Model/om/BaseCategoryVersionPeer.php | 73 +- .../Model/om/BaseCategoryVersionQuery.php | 63 +- core/lib/Thelia/Model/om/BaseCombination.php | 188 +++-- .../Thelia/Model/om/BaseCombinationPeer.php | 37 +- .../Thelia/Model/om/BaseCombinationQuery.php | 52 +- core/lib/Thelia/Model/om/BaseConfig.php | 167 ++-- core/lib/Thelia/Model/om/BaseConfigI18n.php | 72 +- .../Thelia/Model/om/BaseConfigI18nPeer.php | 49 +- .../Thelia/Model/om/BaseConfigI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseConfigPeer.php | 57 +- core/lib/Thelia/Model/om/BaseConfigQuery.php | 60 +- core/lib/Thelia/Model/om/BaseContent.php | 492 +++++++----- core/lib/Thelia/Model/om/BaseContentAssoc.php | 130 +-- .../Thelia/Model/om/BaseContentAssocPeer.php | 55 +- .../Thelia/Model/om/BaseContentAssocQuery.php | 68 +- .../lib/Thelia/Model/om/BaseContentFolder.php | 104 ++- .../Thelia/Model/om/BaseContentFolderPeer.php | 37 +- .../Model/om/BaseContentFolderQuery.php | 58 +- core/lib/Thelia/Model/om/BaseContentI18n.php | 72 +- .../Thelia/Model/om/BaseContentI18nPeer.php | 49 +- .../Thelia/Model/om/BaseContentI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseContentPeer.php | 63 +- core/lib/Thelia/Model/om/BaseContentQuery.php | 87 +- .../Thelia/Model/om/BaseContentVersion.php | 141 ++-- .../Model/om/BaseContentVersionPeer.php | 61 +- .../Model/om/BaseContentVersionQuery.php | 60 +- core/lib/Thelia/Model/om/BaseCountry.php | 224 +++--- core/lib/Thelia/Model/om/BaseCountryI18n.php | 72 +- .../Thelia/Model/om/BaseCountryI18nPeer.php | 49 +- .../Thelia/Model/om/BaseCountryI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseCountryPeer.php | 57 +- core/lib/Thelia/Model/om/BaseCountryQuery.php | 65 +- core/lib/Thelia/Model/om/BaseCoupon.php | 217 ++--- core/lib/Thelia/Model/om/BaseCouponOrder.php | 108 ++- .../Thelia/Model/om/BaseCouponOrderPeer.php | 49 +- .../Thelia/Model/om/BaseCouponOrderQuery.php | 54 +- core/lib/Thelia/Model/om/BaseCouponPeer.php | 73 +- core/lib/Thelia/Model/om/BaseCouponQuery.php | 57 +- core/lib/Thelia/Model/om/BaseCouponRule.php | 114 +-- .../Thelia/Model/om/BaseCouponRulePeer.php | 55 +- .../Thelia/Model/om/BaseCouponRuleQuery.php | 54 +- core/lib/Thelia/Model/om/BaseCurrency.php | 161 ++-- core/lib/Thelia/Model/om/BaseCurrencyPeer.php | 61 +- .../lib/Thelia/Model/om/BaseCurrencyQuery.php | 54 +- core/lib/Thelia/Model/om/BaseCustomer.php | 318 ++++---- core/lib/Thelia/Model/om/BaseCustomerPeer.php | 157 ++-- .../lib/Thelia/Model/om/BaseCustomerQuery.php | 68 +- .../lib/Thelia/Model/om/BaseCustomerTitle.php | 253 +++--- .../Thelia/Model/om/BaseCustomerTitleI18n.php | 60 +- .../Model/om/BaseCustomerTitleI18nPeer.php | 37 +- .../Model/om/BaseCustomerTitleI18nQuery.php | 33 +- .../Thelia/Model/om/BaseCustomerTitlePeer.php | 45 +- .../Model/om/BaseCustomerTitleQuery.php | 65 +- core/lib/Thelia/Model/om/BaseDelivzone.php | 102 ++- .../lib/Thelia/Model/om/BaseDelivzonePeer.php | 43 +- .../Thelia/Model/om/BaseDelivzoneQuery.php | 51 +- core/lib/Thelia/Model/om/BaseDocument.php | 211 +++-- core/lib/Thelia/Model/om/BaseDocumentI18n.php | 72 +- .../Thelia/Model/om/BaseDocumentI18nPeer.php | 49 +- .../Thelia/Model/om/BaseDocumentI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseDocumentPeer.php | 69 +- .../lib/Thelia/Model/om/BaseDocumentQuery.php | 85 +- core/lib/Thelia/Model/om/BaseFeature.php | 308 ++++--- core/lib/Thelia/Model/om/BaseFeatureAv.php | 206 +++-- .../lib/Thelia/Model/om/BaseFeatureAvI18n.php | 72 +- .../Thelia/Model/om/BaseFeatureAvI18nPeer.php | 49 +- .../Model/om/BaseFeatureAvI18nQuery.php | 33 +- .../lib/Thelia/Model/om/BaseFeatureAvPeer.php | 39 +- .../Thelia/Model/om/BaseFeatureAvQuery.php | 65 +- .../Thelia/Model/om/BaseFeatureCategory.php | 110 ++- .../Model/om/BaseFeatureCategoryPeer.php | 43 +- .../Model/om/BaseFeatureCategoryQuery.php | 58 +- core/lib/Thelia/Model/om/BaseFeatureI18n.php | 72 +- .../Thelia/Model/om/BaseFeatureI18nPeer.php | 49 +- .../Thelia/Model/om/BaseFeatureI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseFeaturePeer.php | 45 +- core/lib/Thelia/Model/om/BaseFeatureProd.php | 136 ++-- .../Thelia/Model/om/BaseFeatureProdPeer.php | 61 +- .../Thelia/Model/om/BaseFeatureProdQuery.php | 68 +- core/lib/Thelia/Model/om/BaseFeatureQuery.php | 72 +- core/lib/Thelia/Model/om/BaseFolder.php | 455 ++++++----- core/lib/Thelia/Model/om/BaseFolderI18n.php | 72 +- .../Thelia/Model/om/BaseFolderI18nPeer.php | 49 +- .../Thelia/Model/om/BaseFolderI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseFolderPeer.php | 75 +- core/lib/Thelia/Model/om/BaseFolderQuery.php | 86 +- .../lib/Thelia/Model/om/BaseFolderVersion.php | 153 ++-- .../Thelia/Model/om/BaseFolderVersionPeer.php | 73 +- .../Model/om/BaseFolderVersionQuery.php | 63 +- core/lib/Thelia/Model/om/BaseGroup.php | 300 ++++--- core/lib/Thelia/Model/om/BaseGroupI18n.php | 72 +- .../lib/Thelia/Model/om/BaseGroupI18nPeer.php | 49 +- .../Thelia/Model/om/BaseGroupI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseGroupModule.php | 116 +-- .../Thelia/Model/om/BaseGroupModulePeer.php | 49 +- .../Thelia/Model/om/BaseGroupModuleQuery.php | 61 +- core/lib/Thelia/Model/om/BaseGroupPeer.php | 39 +- core/lib/Thelia/Model/om/BaseGroupQuery.php | 66 +- .../lib/Thelia/Model/om/BaseGroupResource.php | 122 +-- .../Thelia/Model/om/BaseGroupResourcePeer.php | 55 +- .../Model/om/BaseGroupResourceQuery.php | 64 +- core/lib/Thelia/Model/om/BaseImage.php | 211 +++-- core/lib/Thelia/Model/om/BaseImageI18n.php | 72 +- .../lib/Thelia/Model/om/BaseImageI18nPeer.php | 49 +- .../Thelia/Model/om/BaseImageI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseImagePeer.php | 69 +- core/lib/Thelia/Model/om/BaseImageQuery.php | 85 +- core/lib/Thelia/Model/om/BaseLang.php | 112 +-- core/lib/Thelia/Model/om/BaseLangPeer.php | 61 +- core/lib/Thelia/Model/om/BaseLangQuery.php | 47 +- core/lib/Thelia/Model/om/BaseMessage.php | 251 +++--- core/lib/Thelia/Model/om/BaseMessageI18n.php | 66 +- .../Thelia/Model/om/BaseMessageI18nPeer.php | 43 +- .../Thelia/Model/om/BaseMessageI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseMessagePeer.php | 69 +- core/lib/Thelia/Model/om/BaseMessageQuery.php | 64 +- .../Thelia/Model/om/BaseMessageVersion.php | 147 ++-- .../Model/om/BaseMessageVersionPeer.php | 67 +- .../Model/om/BaseMessageVersionQuery.php | 57 +- core/lib/Thelia/Model/om/BaseModule.php | 216 +++-- core/lib/Thelia/Model/om/BaseModuleI18n.php | 72 +- .../Thelia/Model/om/BaseModuleI18nPeer.php | 49 +- .../Thelia/Model/om/BaseModuleI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseModulePeer.php | 57 +- core/lib/Thelia/Model/om/BaseModuleQuery.php | 67 +- core/lib/Thelia/Model/om/BaseOrder.php | 335 ++++---- core/lib/Thelia/Model/om/BaseOrderAddress.php | 246 +++--- .../Thelia/Model/om/BaseOrderAddressPeer.php | 97 +-- .../Thelia/Model/om/BaseOrderAddressQuery.php | 58 +- core/lib/Thelia/Model/om/BaseOrderFeature.php | 108 ++- .../Thelia/Model/om/BaseOrderFeaturePeer.php | 49 +- .../Thelia/Model/om/BaseOrderFeatureQuery.php | 51 +- core/lib/Thelia/Model/om/BaseOrderPeer.php | 121 +-- core/lib/Thelia/Model/om/BaseOrderProduct.php | 195 +++-- .../Thelia/Model/om/BaseOrderProductPeer.php | 85 +- .../Thelia/Model/om/BaseOrderProductQuery.php | 67 +- core/lib/Thelia/Model/om/BaseOrderQuery.php | 93 ++- core/lib/Thelia/Model/om/BaseOrderStatus.php | 198 +++-- .../Thelia/Model/om/BaseOrderStatusI18n.php | 72 +- .../Model/om/BaseOrderStatusI18nPeer.php | 49 +- .../Model/om/BaseOrderStatusI18nQuery.php | 33 +- .../Thelia/Model/om/BaseOrderStatusPeer.php | 39 +- .../Thelia/Model/om/BaseOrderStatusQuery.php | 58 +- core/lib/Thelia/Model/om/BaseProduct.php | 758 +++++++++++------- .../Thelia/Model/om/BaseProductCategory.php | 104 ++- .../Model/om/BaseProductCategoryPeer.php | 37 +- .../Model/om/BaseProductCategoryQuery.php | 58 +- core/lib/Thelia/Model/om/BaseProductI18n.php | 72 +- .../Thelia/Model/om/BaseProductI18nPeer.php | 49 +- .../Thelia/Model/om/BaseProductI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseProductPeer.php | 117 +-- core/lib/Thelia/Model/om/BaseProductQuery.php | 131 +-- .../Thelia/Model/om/BaseProductVersion.php | 195 +++-- .../Model/om/BaseProductVersionPeer.php | 115 +-- .../Model/om/BaseProductVersionQuery.php | 84 +- core/lib/Thelia/Model/om/BaseResource.php | 200 +++-- core/lib/Thelia/Model/om/BaseResourceI18n.php | 72 +- .../Thelia/Model/om/BaseResourceI18nPeer.php | 49 +- .../Thelia/Model/om/BaseResourceI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseResourcePeer.php | 39 +- .../lib/Thelia/Model/om/BaseResourceQuery.php | 58 +- core/lib/Thelia/Model/om/BaseRewriting.php | 144 ++-- .../lib/Thelia/Model/om/BaseRewritingPeer.php | 61 +- .../Thelia/Model/om/BaseRewritingQuery.php | 72 +- core/lib/Thelia/Model/om/BaseStock.php | 122 +-- core/lib/Thelia/Model/om/BaseStockPeer.php | 55 +- core/lib/Thelia/Model/om/BaseStockQuery.php | 64 +- core/lib/Thelia/Model/om/BaseTax.php | 198 +++-- core/lib/Thelia/Model/om/BaseTaxI18n.php | 60 +- core/lib/Thelia/Model/om/BaseTaxI18nPeer.php | 37 +- core/lib/Thelia/Model/om/BaseTaxI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseTaxPeer.php | 39 +- core/lib/Thelia/Model/om/BaseTaxQuery.php | 61 +- core/lib/Thelia/Model/om/BaseTaxRule.php | 259 +++--- .../Thelia/Model/om/BaseTaxRuleCountry.php | 130 +-- .../Model/om/BaseTaxRuleCountryPeer.php | 55 +- .../Model/om/BaseTaxRuleCountryQuery.php | 68 +- core/lib/Thelia/Model/om/BaseTaxRuleI18n.php | 48 +- .../Thelia/Model/om/BaseTaxRuleI18nPeer.php | 25 +- .../Thelia/Model/om/BaseTaxRuleI18nQuery.php | 33 +- core/lib/Thelia/Model/om/BaseTaxRulePeer.php | 51 +- core/lib/Thelia/Model/om/BaseTaxRuleQuery.php | 62 +- 302 files changed, 14189 insertions(+), 8857 deletions(-) diff --git a/composer.json b/composer.json index 3d55fa547..94e9f93f4 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "require":{ "php": ">=5.4.0", "ircmaxell/password-compat": "dev-master", - "propel/propel1" : "1.6.7", + "propel/propel1" : "1.6.*", "psr/log" : "dev-master", "symfony/class-loader": "2.1.*", "symfony/config" : "2.1.*", diff --git a/composer.lock b/composer.lock index 2333d1650..58af68376 100644 --- a/composer.lock +++ b/composer.lock @@ -7,15 +7,15 @@ "source": { "type": "git", "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "fc4ad2d46794ace07cbf04fe654a8bf546fc6764" + "reference": "733c06c599bfeb511f54253ddb127701bce0917d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/fc4ad2d46794ace07cbf04fe654a8bf546fc6764", - "reference": "fc4ad2d46794ace07cbf04fe654a8bf546fc6764", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/733c06c599bfeb511f54253ddb127701bce0917d", + "reference": "733c06c599bfeb511f54253ddb127701bce0917d", "shasum": "" }, - "time": "2013-02-04 16:45:02", + "time": "2013-02-13 16:58:34", "type": "library", "autoload": { "files": [ @@ -36,28 +36,28 @@ "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", "homepage": "https://github.com/ircmaxell/password_compat", "keywords": [ - "password", - "hashing" + "hashing", + "password" ] }, { "name": "phing/phing", - "version": "2.4.14", + "version": "2.5.0", "source": { "type": "git", - "url": "https://github.com/phingofficial/phing", - "reference": "2.4.14" + "url": "https://github.com/phingofficial/phing.git", + "reference": "2.5.0" }, "dist": { "type": "zip", - "url": "https://github.com/phingofficial/phing/archive/2.4.14.zip", - "reference": "2.4.14", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/2.5.0", + "reference": "2.5.0", "shasum": "" }, "require": { "php": ">=5.2.0" }, - "time": "2012-11-29 21:23:47", + "time": "2013-02-16 14:23:57", "bin": [ "bin/phing" ], @@ -94,23 +94,23 @@ }, { "name": "propel/propel1", - "version": "1.6.7", + "version": "1.6.8", "source": { "type": "git", - "url": "https://github.com/propelorm/Propel", - "reference": "1.6.7" + "url": "https://github.com/propelorm/Propel.git", + "reference": "1.6.8" }, "dist": { "type": "zip", - "url": "https://github.com/propelorm/Propel/zipball/1.6.7", - "reference": "1.6.7", + "url": "https://api.github.com/repos/propelorm/Propel/zipball/1.6.8", + "reference": "1.6.8", "shasum": "" }, "require": { - "php": ">=5.2.4", - "phing/phing": ">=2.4.12,2.4.*" + "phing/phing": ">=2.4,<3.0", + "php": ">=5.2.4" }, - "time": "2012-07-30 00:58:15", + "time": "2013-02-14 20:50:27", "bin": [ "generator/bin/propel-gen", "generator/bin/propel-gen.bat" @@ -145,11 +145,11 @@ "description": "Propel is an open-source Object-Relational Mapping (ORM) for PHP5.", "homepage": "http://www.propelorm.org/", "keywords": [ - "database", - "orm", - "persistence", "Active Record", - "mapping" + "database", + "mapping", + "orm", + "persistence" ] }, { @@ -338,12 +338,12 @@ "php": ">=5.3.3" }, "require-dev": { - "symfony/yaml": "2.1.*", - "symfony/config": "2.1.*" + "symfony/config": "2.1.*", + "symfony/yaml": "2.1.*" }, "suggest": { - "symfony/yaml": "2.1.*", - "symfony/config": "2.1.*" + "symfony/config": "2.1.*", + "symfony/yaml": "2.1.*" }, "time": "2013-01-17 21:21:51", "type": "library", @@ -542,15 +542,15 @@ "php": ">=5.3.3" }, "require-dev": { + "doctrine/common": ">=2.2,<2.4-dev", "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*", "symfony/http-kernel": "2.1.*", - "doctrine/common": ">=2.2,<2.4-dev" + "symfony/yaml": "2.1.*" }, "suggest": { + "doctrine/common": ">=2.2,<2.4-dev", "symfony/config": "2.1.*", - "symfony/yaml": "2.1.*", - "doctrine/common": ">=2.2,<2.4-dev" + "symfony/yaml": "2.1.*" }, "time": "2013-01-09 08:51:07", "type": "library", diff --git a/core/lib/Thelia/Model/map/AccessoryTableMap.php b/core/lib/Thelia/Model/map/AccessoryTableMap.php index 9693be79b..92234c2ad 100644 --- a/core/lib/Thelia/Model/map/AccessoryTableMap.php +++ b/core/lib/Thelia/Model/map/AccessoryTableMap.php @@ -42,12 +42,12 @@ class AccessoryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addForeignKey('ACCESSORY', 'Accessory', 'INTEGER', 'product', 'ID', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); + $this->addForeignKey('accessory', 'Accessory', 'INTEGER', 'product', 'id', true, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,7 +69,11 @@ class AccessoryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AddressTableMap.php b/core/lib/Thelia/Model/map/AddressTableMap.php index d1bd7cf74..3005b2b89 100644 --- a/core/lib/Thelia/Model/map/AddressTableMap.php +++ b/core/lib/Thelia/Model/map/AddressTableMap.php @@ -42,22 +42,22 @@ class AddressTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null); - $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null); - $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', true, 255, null); - $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null); - $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', true, null, null); + $this->addForeignKey('customer_title_id', 'CustomerTitleId', 'INTEGER', 'customer_title', 'id', false, null, null); + $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); + $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); + $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); + $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); + $this->addColumn('address2', 'Address2', 'VARCHAR', true, 255, null); + $this->addColumn('address3', 'Address3', 'VARCHAR', true, 255, null); + $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', true, 10, null); + $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); + $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); + $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -79,7 +79,11 @@ class AddressTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AdminGroupTableMap.php b/core/lib/Thelia/Model/map/AdminGroupTableMap.php index 434cf1d82..1898040fe 100644 --- a/core/lib/Thelia/Model/map/AdminGroupTableMap.php +++ b/core/lib/Thelia/Model/map/AdminGroupTableMap.php @@ -42,11 +42,11 @@ class AdminGroupTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', false, null, null); - $this->addForeignKey('ADMIN_ID', 'AdminId', 'INTEGER', 'admin', 'ID', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('group_id', 'GroupId', 'INTEGER', 'group', 'id', false, null, null); + $this->addForeignKey('admin_id', 'AdminId', 'INTEGER', 'admin', 'id', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class AdminGroupTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AdminLogTableMap.php b/core/lib/Thelia/Model/map/AdminLogTableMap.php index 1ebb93098..4c4698279 100644 --- a/core/lib/Thelia/Model/map/AdminLogTableMap.php +++ b/core/lib/Thelia/Model/map/AdminLogTableMap.php @@ -42,14 +42,14 @@ class AdminLogTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('ADMIN_LOGIN', 'AdminLogin', 'VARCHAR', false, 255, null); - $this->addColumn('ADMIN_FIRSTNAME', 'AdminFirstname', 'VARCHAR', false, 255, null); - $this->addColumn('ADMIN_LASTNAME', 'AdminLastname', 'VARCHAR', false, 255, null); - $this->addColumn('ACTION', 'Action', 'VARCHAR', false, 255, null); - $this->addColumn('REQUEST', 'Request', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('admin_login', 'AdminLogin', 'VARCHAR', false, 255, null); + $this->addColumn('admin_firstname', 'AdminFirstname', 'VARCHAR', false, 255, null); + $this->addColumn('admin_lastname', 'AdminLastname', 'VARCHAR', false, 255, null); + $this->addColumn('action', 'Action', 'VARCHAR', false, 255, null); + $this->addColumn('request', 'Request', 'LONGVARCHAR', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,7 +69,11 @@ class AdminLogTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AdminTableMap.php b/core/lib/Thelia/Model/map/AdminTableMap.php index 125c9f9cc..1d679ddda 100644 --- a/core/lib/Thelia/Model/map/AdminTableMap.php +++ b/core/lib/Thelia/Model/map/AdminTableMap.php @@ -42,15 +42,15 @@ class AdminTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 100, null); - $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 100, null); - $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 100, null); - $this->addColumn('PASSWORD', 'Password', 'VARCHAR', true, 128, null); - $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); - $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 100, null); + $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 100, null); + $this->addColumn('login', 'Login', 'VARCHAR', true, 100, null); + $this->addColumn('password', 'Password', 'VARCHAR', true, 128, null); + $this->addColumn('algo', 'Algo', 'VARCHAR', false, 128, null); + $this->addColumn('salt', 'Salt', 'VARCHAR', false, 128, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -71,7 +71,11 @@ class AdminTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AreaTableMap.php b/core/lib/Thelia/Model/map/AreaTableMap.php index c2768651f..5fffa8cab 100644 --- a/core/lib/Thelia/Model/map/AreaTableMap.php +++ b/core/lib/Thelia/Model/map/AreaTableMap.php @@ -42,11 +42,11 @@ class AreaTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null); - $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 100, null); + $this->addColumn('unit', 'Unit', 'FLOAT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class AreaTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php index ec2a5bf0d..449d28112 100644 --- a/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php @@ -42,12 +42,12 @@ class AttributeAvI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'attribute_av', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/AttributeAvTableMap.php b/core/lib/Thelia/Model/map/AttributeAvTableMap.php index be008dc76..9938cf156 100644 --- a/core/lib/Thelia/Model/map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeAvTableMap.php @@ -42,11 +42,11 @@ class AttributeAvTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('attribute_id', 'AttributeId', 'INTEGER', 'attribute', 'id', true, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,8 +69,20 @@ class AttributeAvTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php index a77353836..435c7ed14 100644 --- a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php @@ -42,11 +42,11 @@ class AttributeCategoryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); - $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', true, null, null); + $this->addForeignKey('attribute_id', 'AttributeId', 'INTEGER', 'attribute', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class AttributeCategoryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php index 6ddd955ca..2a6b1c570 100644 --- a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php @@ -42,12 +42,12 @@ class AttributeCombinationTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addForeignPrimaryKey('COMBINATION_ID', 'CombinationId', 'INTEGER' , 'combination', 'ID', true, null, null); - $this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignPrimaryKey('attribute_id', 'AttributeId', 'INTEGER' , 'attribute', 'id', true, null, null); + $this->addForeignPrimaryKey('combination_id', 'CombinationId', 'INTEGER' , 'combination', 'id', true, null, null); + $this->addForeignPrimaryKey('attribute_av_id', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,7 +70,11 @@ class AttributeCombinationTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/map/AttributeI18nTableMap.php index 9a6e570bc..41b40bf43 100644 --- a/core/lib/Thelia/Model/map/AttributeI18nTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeI18nTableMap.php @@ -42,12 +42,12 @@ class AttributeI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'attribute', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/AttributeTableMap.php b/core/lib/Thelia/Model/map/AttributeTableMap.php index 96880b24a..78c47d3c7 100644 --- a/core/lib/Thelia/Model/map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeTableMap.php @@ -42,10 +42,10 @@ class AttributeTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,8 +69,20 @@ class AttributeTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/map/CategoryI18nTableMap.php index 788e303a8..9e6d287cf 100644 --- a/core/lib/Thelia/Model/map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/map/CategoryI18nTableMap.php @@ -42,12 +42,12 @@ class CategoryI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'category', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/CategoryTableMap.php b/core/lib/Thelia/Model/map/CategoryTableMap.php index f902303a4..1440f4683 100644 --- a/core/lib/Thelia/Model/map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/map/CategoryTableMap.php @@ -42,16 +42,16 @@ class CategoryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('parent', 'Parent', 'INTEGER', false, null, null); + $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); + $this->addColumn('visible', 'Visible', 'TINYINT', true, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() @@ -80,9 +80,30 @@ class CategoryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), - 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), + 'versionable' => array ( + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'true', + 'log_created_by' => 'true', + 'log_comment' => 'false', + 'version_created_at_column' => 'version_created_at', + 'version_created_by_column' => 'version_created_by', + 'version_comment_column' => 'version_comment', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/map/CategoryVersionTableMap.php index 64d7f7268..9dbe0497e 100644 --- a/core/lib/Thelia/Model/map/CategoryVersionTableMap.php +++ b/core/lib/Thelia/Model/map/CategoryVersionTableMap.php @@ -42,16 +42,16 @@ class CategoryVersionTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'category', 'id', true, null, null); + $this->addColumn('parent', 'Parent', 'INTEGER', false, null, null); + $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); + $this->addColumn('visible', 'Visible', 'TINYINT', true, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('version', 'Version', 'INTEGER', true, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/CombinationTableMap.php b/core/lib/Thelia/Model/map/CombinationTableMap.php index b975b1fbf..8e14e8cf5 100644 --- a/core/lib/Thelia/Model/map/CombinationTableMap.php +++ b/core/lib/Thelia/Model/map/CombinationTableMap.php @@ -42,10 +42,10 @@ class CombinationTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', false, 255, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,7 +67,11 @@ class CombinationTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/map/ConfigI18nTableMap.php index 8cb51434d..68e73e3c4 100644 --- a/core/lib/Thelia/Model/map/ConfigI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ConfigI18nTableMap.php @@ -42,12 +42,12 @@ class ConfigI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'config', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ConfigTableMap.php b/core/lib/Thelia/Model/map/ConfigTableMap.php index b52137f78..33e45c37b 100644 --- a/core/lib/Thelia/Model/map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/map/ConfigTableMap.php @@ -42,13 +42,13 @@ class ConfigTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, null); - $this->addColumn('VALUE', 'Value', 'VARCHAR', true, 255, null); - $this->addColumn('SECURED', 'Secured', 'TINYINT', true, null, 1); - $this->addColumn('HIDDEN', 'Hidden', 'TINYINT', true, null, 1); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); + $this->addColumn('value', 'Value', 'VARCHAR', true, 255, null); + $this->addColumn('secured', 'Secured', 'TINYINT', true, null, 1); + $this->addColumn('hidden', 'Hidden', 'TINYINT', true, null, 1); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,8 +69,20 @@ class ConfigTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ContentAssocTableMap.php b/core/lib/Thelia/Model/map/ContentAssocTableMap.php index b0b0a8f39..39bea3804 100644 --- a/core/lib/Thelia/Model/map/ContentAssocTableMap.php +++ b/core/lib/Thelia/Model/map/ContentAssocTableMap.php @@ -42,13 +42,13 @@ class ContentAssocTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); + $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -71,7 +71,11 @@ class ContentAssocTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ContentFolderTableMap.php b/core/lib/Thelia/Model/map/ContentFolderTableMap.php index 796e90234..9ea3be3c2 100644 --- a/core/lib/Thelia/Model/map/ContentFolderTableMap.php +++ b/core/lib/Thelia/Model/map/ContentFolderTableMap.php @@ -42,10 +42,10 @@ class ContentFolderTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addForeignPrimaryKey('content_id', 'ContentId', 'INTEGER' , 'content', 'id', true, null, null); + $this->addForeignPrimaryKey('folder_id', 'FolderId', 'INTEGER' , 'folder', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,7 +67,11 @@ class ContentFolderTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ContentI18nTableMap.php b/core/lib/Thelia/Model/map/ContentI18nTableMap.php index f35270b7b..f0e0e6562 100644 --- a/core/lib/Thelia/Model/map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ContentI18nTableMap.php @@ -42,12 +42,12 @@ class ContentI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'content', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php index 68f66d2f4..a18f1a4e6 100644 --- a/core/lib/Thelia/Model/map/ContentTableMap.php +++ b/core/lib/Thelia/Model/map/ContentTableMap.php @@ -42,14 +42,14 @@ class ContentTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() @@ -76,9 +76,30 @@ class ContentTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), - 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), + 'versionable' => array ( + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'true', + 'log_created_by' => 'true', + 'log_comment' => 'false', + 'version_created_at_column' => 'version_created_at', + 'version_created_by_column' => 'version_created_by', + 'version_comment_column' => 'version_comment', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ContentVersionTableMap.php b/core/lib/Thelia/Model/map/ContentVersionTableMap.php index 16852708d..0f1eabe01 100644 --- a/core/lib/Thelia/Model/map/ContentVersionTableMap.php +++ b/core/lib/Thelia/Model/map/ContentVersionTableMap.php @@ -42,14 +42,14 @@ class ContentVersionTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'content', 'id', true, null, null); + $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('version', 'Version', 'INTEGER', true, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/CountryI18nTableMap.php b/core/lib/Thelia/Model/map/CountryI18nTableMap.php index a89d77fda..698d4d209 100644 --- a/core/lib/Thelia/Model/map/CountryI18nTableMap.php +++ b/core/lib/Thelia/Model/map/CountryI18nTableMap.php @@ -42,12 +42,12 @@ class CountryI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'country', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/CountryTableMap.php b/core/lib/Thelia/Model/map/CountryTableMap.php index 110bfd2ff..3c4f83b7c 100644 --- a/core/lib/Thelia/Model/map/CountryTableMap.php +++ b/core/lib/Thelia/Model/map/CountryTableMap.php @@ -42,13 +42,13 @@ class CountryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null); - $this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null); - $this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null); - $this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('area_id', 'AreaId', 'INTEGER', 'area', 'id', false, null, null); + $this->addColumn('isocode', 'Isocode', 'VARCHAR', true, 4, null); + $this->addColumn('isoalpha2', 'Isoalpha2', 'VARCHAR', false, 2, null); + $this->addColumn('isoalpha3', 'Isoalpha3', 'VARCHAR', false, 4, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -71,8 +71,20 @@ class CountryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CouponOrderTableMap.php b/core/lib/Thelia/Model/map/CouponOrderTableMap.php index 9c84f7052..98c71d816 100644 --- a/core/lib/Thelia/Model/map/CouponOrderTableMap.php +++ b/core/lib/Thelia/Model/map/CouponOrderTableMap.php @@ -42,12 +42,12 @@ class CouponOrderTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('order_id', 'OrderId', 'INTEGER', 'order', 'id', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('value', 'Value', 'FLOAT', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class CouponOrderTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CouponRuleTableMap.php b/core/lib/Thelia/Model/map/CouponRuleTableMap.php index 5213b0607..3b29f1ebe 100644 --- a/core/lib/Thelia/Model/map/CouponRuleTableMap.php +++ b/core/lib/Thelia/Model/map/CouponRuleTableMap.php @@ -42,13 +42,13 @@ class CouponRuleTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('COUPON_ID', 'CouponId', 'INTEGER', 'coupon', 'ID', true, null, null); - $this->addColumn('CONTROLLER', 'Controller', 'VARCHAR', false, 255, null); - $this->addColumn('OPERATION', 'Operation', 'VARCHAR', false, 255, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('coupon_id', 'CouponId', 'INTEGER', 'coupon', 'id', true, null, null); + $this->addColumn('controller', 'Controller', 'VARCHAR', false, 255, null); + $this->addColumn('operation', 'Operation', 'VARCHAR', false, 255, null); + $this->addColumn('value', 'Value', 'FLOAT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,7 +69,11 @@ class CouponRuleTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CouponTableMap.php b/core/lib/Thelia/Model/map/CouponTableMap.php index ac1b4f980..714d824c6 100644 --- a/core/lib/Thelia/Model/map/CouponTableMap.php +++ b/core/lib/Thelia/Model/map/CouponTableMap.php @@ -42,16 +42,16 @@ class CouponTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); - $this->addColumn('USED', 'Used', 'TINYINT', false, null, null); - $this->addColumn('AVAILABLE_SINCE', 'AvailableSince', 'TIMESTAMP', false, null, null); - $this->addColumn('DATE_LIMIT', 'DateLimit', 'TIMESTAMP', false, null, null); - $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('action', 'Action', 'VARCHAR', true, 255, null); + $this->addColumn('value', 'Value', 'FLOAT', true, null, null); + $this->addColumn('used', 'Used', 'TINYINT', false, null, null); + $this->addColumn('available_since', 'AvailableSince', 'TIMESTAMP', false, null, null); + $this->addColumn('date_limit', 'DateLimit', 'TIMESTAMP', false, null, null); + $this->addColumn('activate', 'Activate', 'TINYINT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -72,7 +72,11 @@ class CouponTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CurrencyTableMap.php b/core/lib/Thelia/Model/map/CurrencyTableMap.php index e4ff7bd19..14f4089ae 100644 --- a/core/lib/Thelia/Model/map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/map/CurrencyTableMap.php @@ -42,14 +42,14 @@ class CurrencyTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null); - $this->addColumn('RATE', 'Rate', 'FLOAT', false, null, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', false, 45, null); + $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); + $this->addColumn('symbol', 'Symbol', 'VARCHAR', false, 45, null); + $this->addColumn('rate', 'Rate', 'FLOAT', false, null, null); + $this->addColumn('by_default', 'ByDefault', 'TINYINT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,7 +70,11 @@ class CurrencyTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CustomerTableMap.php b/core/lib/Thelia/Model/map/CustomerTableMap.php index 59fa9be3a..8f6d9bbe2 100644 --- a/core/lib/Thelia/Model/map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTableMap.php @@ -42,30 +42,30 @@ class CustomerTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null); - $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null); - $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null); - $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null); - $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', false, 10, null); - $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null); - $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null); - $this->addColumn('PASSWORD', 'Password', 'VARCHAR', false, 255, null); - $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null); - $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null); - $this->addColumn('RESELLER', 'Reseller', 'TINYINT', false, null, null); - $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null); - $this->addColumn('SPONSOR', 'Sponsor', 'VARCHAR', false, 50, null); - $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', true, 50, null); + $this->addForeignKey('customer_title_id', 'CustomerTitleId', 'INTEGER', 'customer_title', 'id', false, null, null); + $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); + $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); + $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); + $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); + $this->addColumn('address2', 'Address2', 'VARCHAR', false, 255, null); + $this->addColumn('address3', 'Address3', 'VARCHAR', false, 255, null); + $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', false, 10, null); + $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); + $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); + $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); + $this->addColumn('cellphone', 'Cellphone', 'VARCHAR', false, 20, null); + $this->addColumn('email', 'Email', 'VARCHAR', false, 50, null); + $this->addColumn('password', 'Password', 'VARCHAR', false, 255, null); + $this->addColumn('algo', 'Algo', 'VARCHAR', false, 128, null); + $this->addColumn('salt', 'Salt', 'VARCHAR', false, 128, null); + $this->addColumn('reseller', 'Reseller', 'TINYINT', false, null, null); + $this->addColumn('lang', 'Lang', 'VARCHAR', false, 10, null); + $this->addColumn('sponsor', 'Sponsor', 'VARCHAR', false, 50, null); + $this->addColumn('discount', 'Discount', 'FLOAT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -88,7 +88,11 @@ class CustomerTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php index eebc5ce21..ed7bf6072 100644 --- a/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php @@ -42,10 +42,10 @@ class CustomerTitleI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); - $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'customer_title', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('short', 'Short', 'VARCHAR', false, 10, null); + $this->addColumn('long', 'Long', 'VARCHAR', false, 45, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php index 90c3ff3ff..6fb527a1c 100644 --- a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php @@ -42,11 +42,11 @@ class CustomerTitleTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'INTEGER', true, null, 0); - $this->addColumn('POSITION', 'Position', 'VARCHAR', true, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('by_default', 'ByDefault', 'INTEGER', true, null, 0); + $this->addColumn('position', 'Position', 'VARCHAR', true, 45, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,8 +69,20 @@ class CustomerTitleTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'short, long', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'short, long', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/DelivzoneTableMap.php b/core/lib/Thelia/Model/map/DelivzoneTableMap.php index a0e828669..379da0118 100644 --- a/core/lib/Thelia/Model/map/DelivzoneTableMap.php +++ b/core/lib/Thelia/Model/map/DelivzoneTableMap.php @@ -42,11 +42,11 @@ class DelivzoneTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null); - $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('area_id', 'AreaId', 'INTEGER', 'area', 'id', false, null, null); + $this->addColumn('delivery', 'Delivery', 'VARCHAR', true, 45, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,7 +67,11 @@ class DelivzoneTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/map/DocumentI18nTableMap.php index 4cf4aae99..ea10a0b8c 100644 --- a/core/lib/Thelia/Model/map/DocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/map/DocumentI18nTableMap.php @@ -42,12 +42,12 @@ class DocumentI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'document', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/DocumentTableMap.php b/core/lib/Thelia/Model/map/DocumentTableMap.php index f93d9806d..69f0d90e9 100644 --- a/core/lib/Thelia/Model/map/DocumentTableMap.php +++ b/core/lib/Thelia/Model/map/DocumentTableMap.php @@ -42,15 +42,15 @@ class DocumentTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); + $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); + $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); + $this->addColumn('file', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -75,8 +75,20 @@ class DocumentTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php index eea4107d4..d8f5ef074 100644 --- a/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php @@ -42,12 +42,12 @@ class FeatureAvI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'feature_av', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/FeatureAvTableMap.php b/core/lib/Thelia/Model/map/FeatureAvTableMap.php index 1315199a5..ef1ed57f5 100644 --- a/core/lib/Thelia/Model/map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureAvTableMap.php @@ -42,10 +42,10 @@ class FeatureAvTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,8 +68,20 @@ class FeatureAvTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php index 04f156c6d..63dc296c6 100644 --- a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php @@ -42,11 +42,11 @@ class FeatureCategoryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class FeatureCategoryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/map/FeatureI18nTableMap.php index d38a3758d..7f3ff771c 100644 --- a/core/lib/Thelia/Model/map/FeatureI18nTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureI18nTableMap.php @@ -42,12 +42,12 @@ class FeatureI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'feature', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/FeatureProdTableMap.php b/core/lib/Thelia/Model/map/FeatureProdTableMap.php index 2c0923347..d55478e91 100644 --- a/core/lib/Thelia/Model/map/FeatureProdTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureProdTableMap.php @@ -42,14 +42,14 @@ class FeatureProdTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); - $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); + $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); + $this->addForeignKey('feature_av_id', 'FeatureAvId', 'INTEGER', 'feature_av', 'id', false, null, null); + $this->addColumn('by_default', 'ByDefault', 'VARCHAR', false, 255, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -72,7 +72,11 @@ class FeatureProdTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FeatureTableMap.php b/core/lib/Thelia/Model/map/FeatureTableMap.php index 977554a00..4790256e8 100644 --- a/core/lib/Thelia/Model/map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureTableMap.php @@ -42,11 +42,11 @@ class FeatureTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('visible', 'Visible', 'INTEGER', false, null, 0); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,8 +70,20 @@ class FeatureTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FolderI18nTableMap.php b/core/lib/Thelia/Model/map/FolderI18nTableMap.php index d7af79791..a156d791f 100644 --- a/core/lib/Thelia/Model/map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/map/FolderI18nTableMap.php @@ -42,12 +42,12 @@ class FolderI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'folder', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/FolderTableMap.php b/core/lib/Thelia/Model/map/FolderTableMap.php index e4319f402..5345d1715 100644 --- a/core/lib/Thelia/Model/map/FolderTableMap.php +++ b/core/lib/Thelia/Model/map/FolderTableMap.php @@ -42,16 +42,16 @@ class FolderTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('parent', 'Parent', 'INTEGER', true, null, null); + $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); + $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() @@ -77,9 +77,30 @@ class FolderTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), - 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), + 'versionable' => array ( + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'true', + 'log_created_by' => 'true', + 'log_comment' => 'false', + 'version_created_at_column' => 'version_created_at', + 'version_created_by_column' => 'version_created_by', + 'version_comment_column' => 'version_comment', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/FolderVersionTableMap.php b/core/lib/Thelia/Model/map/FolderVersionTableMap.php index 7a6fe942b..0de9d13c2 100644 --- a/core/lib/Thelia/Model/map/FolderVersionTableMap.php +++ b/core/lib/Thelia/Model/map/FolderVersionTableMap.php @@ -42,16 +42,16 @@ class FolderVersionTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'folder', 'id', true, null, null); + $this->addColumn('parent', 'Parent', 'INTEGER', true, null, null); + $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); + $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('version', 'Version', 'INTEGER', true, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/GroupI18nTableMap.php b/core/lib/Thelia/Model/map/GroupI18nTableMap.php index 2d23fc795..122508186 100644 --- a/core/lib/Thelia/Model/map/GroupI18nTableMap.php +++ b/core/lib/Thelia/Model/map/GroupI18nTableMap.php @@ -42,12 +42,12 @@ class GroupI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'group', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/GroupModuleTableMap.php b/core/lib/Thelia/Model/map/GroupModuleTableMap.php index be397fb41..0db6fd037 100644 --- a/core/lib/Thelia/Model/map/GroupModuleTableMap.php +++ b/core/lib/Thelia/Model/map/GroupModuleTableMap.php @@ -42,12 +42,12 @@ class GroupModuleTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null); - $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null); - $this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('group_id', 'GroupId', 'INTEGER', 'group', 'id', true, null, null); + $this->addForeignKey('module_id', 'ModuleId', 'INTEGER', 'module', 'id', false, null, null); + $this->addColumn('access', 'Access', 'TINYINT', false, null, 0); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,7 +69,11 @@ class GroupModuleTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/GroupResourceTableMap.php b/core/lib/Thelia/Model/map/GroupResourceTableMap.php index a01225633..87270194e 100644 --- a/core/lib/Thelia/Model/map/GroupResourceTableMap.php +++ b/core/lib/Thelia/Model/map/GroupResourceTableMap.php @@ -42,13 +42,13 @@ class GroupResourceTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null); - $this->addForeignKey('RESOURCE_ID', 'ResourceId', 'INTEGER', 'resource', 'ID', true, null, null); - $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0); - $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('group_id', 'GroupId', 'INTEGER', 'group', 'id', true, null, null); + $this->addForeignKey('resource_id', 'ResourceId', 'INTEGER', 'resource', 'id', true, null, null); + $this->addColumn('read', 'Read', 'TINYINT', false, null, 0); + $this->addColumn('write', 'Write', 'TINYINT', false, null, 0); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,7 +70,11 @@ class GroupResourceTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/GroupTableMap.php b/core/lib/Thelia/Model/map/GroupTableMap.php index 097666acb..ffe90f241 100644 --- a/core/lib/Thelia/Model/map/GroupTableMap.php +++ b/core/lib/Thelia/Model/map/GroupTableMap.php @@ -42,10 +42,10 @@ class GroupTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 30, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,8 +69,20 @@ class GroupTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ImageI18nTableMap.php b/core/lib/Thelia/Model/map/ImageI18nTableMap.php index 348690663..111945b6f 100644 --- a/core/lib/Thelia/Model/map/ImageI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ImageI18nTableMap.php @@ -42,12 +42,12 @@ class ImageI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'image', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ImageTableMap.php b/core/lib/Thelia/Model/map/ImageTableMap.php index 71bd8d700..7c9dd1a5b 100644 --- a/core/lib/Thelia/Model/map/ImageTableMap.php +++ b/core/lib/Thelia/Model/map/ImageTableMap.php @@ -42,15 +42,15 @@ class ImageTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); + $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); + $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); + $this->addColumn('file', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -75,8 +75,20 @@ class ImageTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/LangTableMap.php b/core/lib/Thelia/Model/map/LangTableMap.php index e9544d25b..d70450386 100644 --- a/core/lib/Thelia/Model/map/LangTableMap.php +++ b/core/lib/Thelia/Model/map/LangTableMap.php @@ -42,14 +42,14 @@ class LangTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 100, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', false, 10, null); - $this->addColumn('LOCALE', 'Locale', 'VARCHAR', false, 45, null); - $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('title', 'Title', 'VARCHAR', false, 100, null); + $this->addColumn('code', 'Code', 'VARCHAR', false, 10, null); + $this->addColumn('locale', 'Locale', 'VARCHAR', false, 45, null); + $this->addColumn('url', 'Url', 'VARCHAR', false, 255, null); + $this->addColumn('by_default', 'ByDefault', 'TINYINT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -69,7 +69,11 @@ class LangTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/MessageI18nTableMap.php b/core/lib/Thelia/Model/map/MessageI18nTableMap.php index a7660e6fc..fb92e2048 100644 --- a/core/lib/Thelia/Model/map/MessageI18nTableMap.php +++ b/core/lib/Thelia/Model/map/MessageI18nTableMap.php @@ -42,11 +42,11 @@ class MessageI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'message', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'LONGVARCHAR', false, null, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('description_html', 'DescriptionHtml', 'CLOB', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/MessageTableMap.php b/core/lib/Thelia/Model/map/MessageTableMap.php index c20ea6704..f0240f508 100644 --- a/core/lib/Thelia/Model/map/MessageTableMap.php +++ b/core/lib/Thelia/Model/map/MessageTableMap.php @@ -42,15 +42,15 @@ class MessageTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('secured', 'Secured', 'TINYINT', false, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', false, 255, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() @@ -72,9 +72,30 @@ class MessageTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, description_html', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), - 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, description_html', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), + 'versionable' => array ( + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'true', + 'log_created_by' => 'true', + 'log_comment' => 'false', + 'version_created_at_column' => 'version_created_at', + 'version_created_by_column' => 'version_created_by', + 'version_comment_column' => 'version_comment', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/MessageVersionTableMap.php b/core/lib/Thelia/Model/map/MessageVersionTableMap.php index 3cc7e00e1..670d1aad2 100644 --- a/core/lib/Thelia/Model/map/MessageVersionTableMap.php +++ b/core/lib/Thelia/Model/map/MessageVersionTableMap.php @@ -42,15 +42,15 @@ class MessageVersionTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'message', 'id', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('secured', 'Secured', 'TINYINT', false, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', false, 255, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('version', 'Version', 'INTEGER', true, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/map/ModuleI18nTableMap.php index d634ea92a..61247bcf3 100644 --- a/core/lib/Thelia/Model/map/ModuleI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ModuleI18nTableMap.php @@ -42,12 +42,12 @@ class ModuleI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'module', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ModuleTableMap.php b/core/lib/Thelia/Model/map/ModuleTableMap.php index c203d3e88..71c70625f 100644 --- a/core/lib/Thelia/Model/map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/map/ModuleTableMap.php @@ -42,13 +42,13 @@ class ModuleTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 55, null); - $this->addColumn(' TYPE', ' type', 'TINYINT', true, null, null); - $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 55, null); + $this->addColumn(' type', ' type', 'TINYINT', true, null, null); + $this->addColumn('activate', 'Activate', 'TINYINT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,8 +70,20 @@ class ModuleTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/OrderAddressTableMap.php b/core/lib/Thelia/Model/map/OrderAddressTableMap.php index bca5ff446..0ac4dde41 100644 --- a/core/lib/Thelia/Model/map/OrderAddressTableMap.php +++ b/core/lib/Thelia/Model/map/OrderAddressTableMap.php @@ -42,20 +42,20 @@ class OrderAddressTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null); - $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null); - $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null); - $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null); - $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('customer_title_id', 'CustomerTitleId', 'INTEGER', false, null, null); + $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); + $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); + $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); + $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); + $this->addColumn('address2', 'Address2', 'VARCHAR', false, 255, null); + $this->addColumn('address3', 'Address3', 'VARCHAR', false, 255, null); + $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', true, 10, null); + $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); + $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); + $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -77,7 +77,11 @@ class OrderAddressTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php index 069e49ea9..0f3a43ffd 100644 --- a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php +++ b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php @@ -42,12 +42,12 @@ class OrderFeatureTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); - $this->addColumn('FEATURE_DESC', 'FeatureDesc', 'VARCHAR', false, 255, null); - $this->addColumn('FEATURE_AV_DESC', 'FeatureAvDesc', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('order_product_id', 'OrderProductId', 'INTEGER', 'order_product', 'id', true, null, null); + $this->addColumn('feature_desc', 'FeatureDesc', 'VARCHAR', false, 255, null); + $this->addColumn('feature_av_desc', 'FeatureAvDesc', 'VARCHAR', false, 255, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,7 +68,11 @@ class OrderFeatureTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/OrderProductTableMap.php b/core/lib/Thelia/Model/map/OrderProductTableMap.php index b673b4fbc..07abe778f 100644 --- a/core/lib/Thelia/Model/map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/map/OrderProductTableMap.php @@ -42,18 +42,18 @@ class OrderProductTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); - $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('order_id', 'OrderId', 'INTEGER', 'order', 'id', true, null, null); + $this->addColumn('product_ref', 'ProductRef', 'VARCHAR', false, 255, null); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('quantity', 'Quantity', 'FLOAT', true, null, null); + $this->addColumn('price', 'Price', 'FLOAT', true, null, null); + $this->addColumn('tax', 'Tax', 'FLOAT', false, null, null); + $this->addColumn('parent', 'Parent', 'INTEGER', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -75,7 +75,11 @@ class OrderProductTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php index d31eb2dd1..594f99f86 100644 --- a/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php +++ b/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php @@ -42,12 +42,12 @@ class OrderStatusI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'order_status', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/OrderStatusTableMap.php b/core/lib/Thelia/Model/map/OrderStatusTableMap.php index 107b7eb74..66284e02f 100644 --- a/core/lib/Thelia/Model/map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/map/OrderStatusTableMap.php @@ -42,10 +42,10 @@ class OrderStatusTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,8 +67,20 @@ class OrderStatusTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/OrderTableMap.php b/core/lib/Thelia/Model/map/OrderTableMap.php index 9f50c2d54..1b7b04013 100644 --- a/core/lib/Thelia/Model/map/OrderTableMap.php +++ b/core/lib/Thelia/Model/map/OrderTableMap.php @@ -42,24 +42,24 @@ class OrderTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null); - $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null); - $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null); - $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null); - $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null); - $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null); - $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null); - $this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null); - $this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null); - $this->addColumn('INVOICE', 'Invoice', 'VARCHAR', false, 100, null); - $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); - $this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null); - $this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null); - $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', false, null, null); - $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', false, 45, null); + $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', true, null, null); + $this->addForeignKey('address_invoice', 'AddressInvoice', 'INTEGER', 'order_address', 'id', false, null, null); + $this->addForeignKey('address_delivery', 'AddressDelivery', 'INTEGER', 'order_address', 'id', false, null, null); + $this->addColumn('invoice_date', 'InvoiceDate', 'DATE', false, null, null); + $this->addForeignKey('currency_id', 'CurrencyId', 'INTEGER', 'currency', 'id', false, null, null); + $this->addColumn('currency_rate', 'CurrencyRate', 'FLOAT', true, null, null); + $this->addColumn('transaction', 'Transaction', 'VARCHAR', false, 100, null); + $this->addColumn('delivery_num', 'DeliveryNum', 'VARCHAR', false, 100, null); + $this->addColumn('invoice', 'Invoice', 'VARCHAR', false, 100, null); + $this->addColumn('postage', 'Postage', 'FLOAT', false, null, null); + $this->addColumn('payment', 'Payment', 'VARCHAR', true, 45, null); + $this->addColumn('carrier', 'Carrier', 'VARCHAR', true, 45, null); + $this->addForeignKey('status_id', 'StatusId', 'INTEGER', 'order_status', 'id', false, null, null); + $this->addColumn('lang', 'Lang', 'VARCHAR', true, 10, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -86,7 +86,11 @@ class OrderTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php index 55dc912d2..f6234eb51 100644 --- a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php @@ -42,10 +42,10 @@ class ProductCategoryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addForeignPrimaryKey('product_id', 'ProductId', 'INTEGER' , 'product', 'id', true, null, null); + $this->addForeignPrimaryKey('category_id', 'CategoryId', 'INTEGER' , 'category', 'id', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,7 +67,11 @@ class ProductCategoryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ProductI18nTableMap.php b/core/lib/Thelia/Model/map/ProductI18nTableMap.php index 6d54a74b1..f94fe6e4b 100644 --- a/core/lib/Thelia/Model/map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ProductI18nTableMap.php @@ -42,12 +42,12 @@ class ProductI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'product', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ProductTableMap.php b/core/lib/Thelia/Model/map/ProductTableMap.php index 926c23e91..382c72f1f 100644 --- a/core/lib/Thelia/Model/map/ProductTableMap.php +++ b/core/lib/Thelia/Model/map/ProductTableMap.php @@ -42,23 +42,23 @@ class ProductTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); - $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null); - $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null); - $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0); - $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0); - $this->addColumn('STOCK', 'Stock', 'INTEGER', false, null, 0); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('tax_rule_id', 'TaxRuleId', 'INTEGER', 'tax_rule', 'id', false, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', true, 255, null); + $this->addColumn('price', 'Price', 'FLOAT', true, null, null); + $this->addColumn('price2', 'Price2', 'FLOAT', false, null, null); + $this->addColumn('ecotax', 'Ecotax', 'FLOAT', false, null, null); + $this->addColumn('newness', 'Newness', 'TINYINT', false, null, 0); + $this->addColumn('promo', 'Promo', 'TINYINT', false, null, 0); + $this->addColumn('stock', 'Stock', 'INTEGER', false, null, 0); + $this->addColumn('visible', 'Visible', 'TINYINT', true, null, 0); + $this->addColumn('weight', 'Weight', 'FLOAT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() @@ -90,9 +90,30 @@ class ProductTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), - 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), + 'versionable' => array ( + 'version_column' => 'version', + 'version_table' => '', + 'log_created_at' => 'true', + 'log_created_by' => 'true', + 'log_comment' => 'false', + 'version_created_at_column' => 'version_created_at', + 'version_created_by_column' => 'version_created_by', + 'version_comment_column' => 'version_comment', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/ProductVersionTableMap.php b/core/lib/Thelia/Model/map/ProductVersionTableMap.php index 3267ac2d4..67c459197 100644 --- a/core/lib/Thelia/Model/map/ProductVersionTableMap.php +++ b/core/lib/Thelia/Model/map/ProductVersionTableMap.php @@ -42,23 +42,23 @@ class ProductVersionTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); - $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null); - $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null); - $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0); - $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0); - $this->addColumn('STOCK', 'Stock', 'INTEGER', false, null, 0); - $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); - $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'product', 'id', true, null, null); + $this->addColumn('tax_rule_id', 'TaxRuleId', 'INTEGER', false, null, null); + $this->addColumn('ref', 'Ref', 'VARCHAR', true, 255, null); + $this->addColumn('price', 'Price', 'FLOAT', true, null, null); + $this->addColumn('price2', 'Price2', 'FLOAT', false, null, null); + $this->addColumn('ecotax', 'Ecotax', 'FLOAT', false, null, null); + $this->addColumn('newness', 'Newness', 'TINYINT', false, null, 0); + $this->addColumn('promo', 'Promo', 'TINYINT', false, null, 0); + $this->addColumn('stock', 'Stock', 'INTEGER', false, null, 0); + $this->addColumn('visible', 'Visible', 'TINYINT', true, null, 0); + $this->addColumn('weight', 'Weight', 'FLOAT', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('version', 'Version', 'INTEGER', true, null, 0); + $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/map/ResourceI18nTableMap.php index 568fa1490..9bf1931e5 100644 --- a/core/lib/Thelia/Model/map/ResourceI18nTableMap.php +++ b/core/lib/Thelia/Model/map/ResourceI18nTableMap.php @@ -42,12 +42,12 @@ class ResourceI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'resource', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'CLOB', false, null, null); + $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/ResourceTableMap.php b/core/lib/Thelia/Model/map/ResourceTableMap.php index 02ee749ba..b42065c43 100644 --- a/core/lib/Thelia/Model/map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/map/ResourceTableMap.php @@ -42,10 +42,10 @@ class ResourceTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', true, 30, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,8 +67,20 @@ class ResourceTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description, chapo, postscriptum', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/RewritingTableMap.php b/core/lib/Thelia/Model/map/RewritingTableMap.php index c1003c2c9..cbf7c5045 100644 --- a/core/lib/Thelia/Model/map/RewritingTableMap.php +++ b/core/lib/Thelia/Model/map/RewritingTableMap.php @@ -42,14 +42,14 @@ class RewritingTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('url', 'Url', 'VARCHAR', true, 255, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); + $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); + $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); + $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -73,7 +73,11 @@ class RewritingTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/StockTableMap.php b/core/lib/Thelia/Model/map/StockTableMap.php index 4e3b2b617..1b32f03df 100644 --- a/core/lib/Thelia/Model/map/StockTableMap.php +++ b/core/lib/Thelia/Model/map/StockTableMap.php @@ -42,13 +42,13 @@ class StockTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', false, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, null); - $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('combination_id', 'CombinationId', 'INTEGER', 'combination', 'id', false, null, null); + $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); + $this->addColumn('increase', 'Increase', 'FLOAT', false, null, null); + $this->addColumn('value', 'Value', 'FLOAT', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,7 +70,11 @@ class StockTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/TaxI18nTableMap.php b/core/lib/Thelia/Model/map/TaxI18nTableMap.php index 48ddc478e..80aab3e83 100644 --- a/core/lib/Thelia/Model/map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/map/TaxI18nTableMap.php @@ -42,10 +42,10 @@ class TaxI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'tax', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php index f4be600bb..cf23d4adf 100644 --- a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php @@ -42,13 +42,13 @@ class TaxRuleCountryTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null); - $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', false, null, null); - $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', false, null, null); - $this->addColumn('NONE', 'None', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('tax_rule_id', 'TaxRuleId', 'INTEGER', 'tax_rule', 'id', false, null, null); + $this->addForeignKey('country_id', 'CountryId', 'INTEGER', 'country', 'id', false, null, null); + $this->addForeignKey('tax_id', 'TaxId', 'INTEGER', 'tax', 'id', false, null, null); + $this->addColumn('none', 'None', 'TINYINT', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -71,7 +71,11 @@ class TaxRuleCountryTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php index 42e7b2a65..b0d07244c 100644 --- a/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php @@ -42,8 +42,8 @@ class TaxRuleI18nTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'tax_rule', 'id', true, null, null); + $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); // validators } // initialize() diff --git a/core/lib/Thelia/Model/map/TaxRuleTableMap.php b/core/lib/Thelia/Model/map/TaxRuleTableMap.php index 51714dc5d..64574acef 100644 --- a/core/lib/Thelia/Model/map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleTableMap.php @@ -42,12 +42,12 @@ class TaxRuleTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); + $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -70,8 +70,20 @@ class TaxRuleTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => '', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/map/TaxTableMap.php b/core/lib/Thelia/Model/map/TaxTableMap.php index 80505fb29..c852fc8d4 100644 --- a/core/lib/Thelia/Model/map/TaxTableMap.php +++ b/core/lib/Thelia/Model/map/TaxTableMap.php @@ -42,10 +42,10 @@ class TaxTableMap extends TableMap $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('rate', 'Rate', 'FLOAT', true, null, null); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -67,8 +67,20 @@ class TaxTableMap extends TableMap public function getBehaviors() { return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description', 'locale_column' => 'locale', 'default_locale' => '', 'locale_alias' => '', ), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'i18n' => array ( + 'i18n_table' => '%TABLE%_i18n', + 'i18n_phpname' => '%PHPNAME%I18n', + 'i18n_columns' => 'title, description', + 'i18n_pk_name' => NULL, + 'locale_column' => 'locale', + 'default_locale' => NULL, + 'locale_alias' => '', +), ); } // getBehaviors() diff --git a/core/lib/Thelia/Model/om/BaseAccessory.php b/core/lib/Thelia/Model/om/BaseAccessory.php index e8e7cfcbd..d01346c03 100644 --- a/core/lib/Thelia/Model/om/BaseAccessory.php +++ b/core/lib/Thelia/Model/om/BaseAccessory.php @@ -107,6 +107,12 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -166,22 +172,25 @@ abstract class BaseAccessory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -203,22 +212,25 @@ abstract class BaseAccessory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -229,7 +241,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -250,7 +262,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -275,7 +287,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ public function setAccessory($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -300,7 +312,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -404,7 +416,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = AccessoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -652,22 +664,22 @@ abstract class BaseAccessory extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AccessoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) { - $modifiedColumns[':p' . $index++] = '`ACCESSORY`'; + $modifiedColumns[':p' . $index++] = '`accessory`'; } if ($this->isColumnModified(AccessoryPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -680,22 +692,22 @@ abstract class BaseAccessory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`ACCESSORY`': + case '`accessory`': $stmt->bindValue($identifier, $this->accessory, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -759,11 +771,11 @@ abstract class BaseAccessory extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1161,12 +1173,13 @@ abstract class BaseAccessory extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProductRelatedByProductId(PropelPDO $con = null) + public function getProductRelatedByProductId(PropelPDO $con = null, $doQuery = true) { - if ($this->aProductRelatedByProductId === null && ($this->product_id !== null)) { + if ($this->aProductRelatedByProductId === null && ($this->product_id !== null) && $doQuery) { $this->aProductRelatedByProductId = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1212,12 +1225,13 @@ abstract class BaseAccessory extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProductRelatedByAccessory(PropelPDO $con = null) + public function getProductRelatedByAccessory(PropelPDO $con = null, $doQuery = true) { - if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null)) { + if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null) && $doQuery) { $this->aProductRelatedByAccessory = ProductQuery::create()->findPk($this->accessory, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1244,6 +1258,7 @@ abstract class BaseAccessory extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1261,7 +1276,16 @@ abstract class BaseAccessory extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProductRelatedByProductId instanceof Persistent) { + $this->aProductRelatedByProductId->clearAllReferences($deep); + } + if ($this->aProductRelatedByAccessory instanceof Persistent) { + $this->aProductRelatedByAccessory->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProductRelatedByProductId = null; diff --git a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php index f9d5ee6e9..7efbf476f 100644 --- a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php @@ -45,23 +45,23 @@ abstract class BaseAccessoryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'accessory.ID'; + /** the column name for the id field */ + const ID = 'accessory.id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'accessory.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'accessory.product_id'; - /** the column name for the ACCESSORY field */ - const ACCESSORY = 'accessory.ACCESSORY'; + /** the column name for the accessory field */ + const ACCESSORY = 'accessory.accessory'; - /** the column name for the POSITION field */ - const POSITION = 'accessory.POSITION'; + /** the column name for the position field */ + const POSITION = 'accessory.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'accessory.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'accessory.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'accessory.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'accessory.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseAccessoryPeer $criteria->addSelectColumn(AccessoryPeer::CREATED_AT); $criteria->addSelectColumn(AccessoryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.ACCESSORY'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.accessory'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -272,7 +272,7 @@ abstract class BaseAccessoryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseAccessoryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AccessoryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AccessoryPeer::$instances = array(); } @@ -1092,7 +1099,7 @@ abstract class BaseAccessoryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AccessoryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php index 9331401fa..3f60bf748 100644 --- a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php @@ -51,7 +51,6 @@ use Thelia\Model\Product; * @method Accessory findOne(PropelPDO $con = null) Return the first Accessory matching the query * @method Accessory findOneOrCreate(PropelPDO $con = null) Return the first Accessory matching the query, or a new Accessory object populated from the query conditions when no match is found * - * @method Accessory findOneById(int $id) Return the first Accessory filtered by the id column * @method Accessory findOneByProductId(int $product_id) Return the first Accessory filtered by the product_id column * @method Accessory findOneByAccessory(int $accessory) Return the first Accessory filtered by the accessory column * @method Accessory findOneByPosition(int $position) Return the first Accessory filtered by the position column @@ -85,7 +84,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * Returns a new AccessoryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AccessoryQuery|Criteria $criteria Optional Criteria to build the query from + * @param AccessoryQuery|Criteria $criteria Optional Criteria to build the query from * * @return AccessoryQuery */ @@ -141,6 +140,20 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Accessory A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -148,12 +161,12 @@ abstract class BaseAccessoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Accessory A model object, or null if the key is not found - * @throws PropelException + * @return Accessory A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `ACCESSORY`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `accessory` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `product_id`, `accessory`, `position`, `created_at`, `updated_at` FROM `accessory` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -249,7 +262,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -262,8 +276,22 @@ abstract class BaseAccessoryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AccessoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AccessoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AccessoryPeer::ID, $id, $comparison); @@ -276,7 +304,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProductRelatedByProductId() @@ -319,7 +348,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $query->filterByAccessory(1234); // WHERE accessory = 1234 * $query->filterByAccessory(array(12, 34)); // WHERE accessory IN (12, 34) - * $query->filterByAccessory(array('min' => 12)); // WHERE accessory > 12 + * $query->filterByAccessory(array('min' => 12)); // WHERE accessory >= 12 + * $query->filterByAccessory(array('max' => 12)); // WHERE accessory <= 12 * * * @see filterByProductRelatedByAccessory() @@ -362,7 +392,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -488,8 +519,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AccessoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AccessoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductRelatedByProductId($product, $comparison = null) { @@ -564,8 +595,8 @@ abstract class BaseAccessoryQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AccessoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AccessoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductRelatedByAccessory($product, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/om/BaseAddress.php index dd1df4e57..62db82dbe 100644 --- a/core/lib/Thelia/Model/om/BaseAddress.php +++ b/core/lib/Thelia/Model/om/BaseAddress.php @@ -169,6 +169,12 @@ abstract class BaseAddress extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -328,22 +334,25 @@ abstract class BaseAddress extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -365,22 +374,25 @@ abstract class BaseAddress extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -391,7 +403,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -412,7 +424,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -433,7 +445,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setCustomerId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -458,7 +470,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setCustomerTitleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -483,7 +495,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setCompany($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -504,7 +516,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setFirstname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -525,7 +537,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setLastname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -546,7 +558,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setAddress1($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -567,7 +579,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setAddress2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -588,7 +600,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setAddress3($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -609,7 +621,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setZipcode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -630,7 +642,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setCity($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -651,7 +663,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setCountryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -672,7 +684,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function setPhone($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -786,7 +798,7 @@ abstract class BaseAddress extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 16; // 16 = AddressPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -1038,52 +1050,52 @@ abstract class BaseAddress extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AddressPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`CUSTOMER_ID`'; + $modifiedColumns[':p' . $index++] = '`customer_id`'; } if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`'; + $modifiedColumns[':p' . $index++] = '`customer_title_id`'; } if ($this->isColumnModified(AddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`COMPANY`'; + $modifiedColumns[':p' . $index++] = '`company`'; } if ($this->isColumnModified(AddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`FIRSTNAME`'; + $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(AddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`LASTNAME`'; + $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(AddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS1`'; + $modifiedColumns[':p' . $index++] = '`address1`'; } if ($this->isColumnModified(AddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS2`'; + $modifiedColumns[':p' . $index++] = '`address2`'; } if ($this->isColumnModified(AddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS3`'; + $modifiedColumns[':p' . $index++] = '`address3`'; } if ($this->isColumnModified(AddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`ZIPCODE`'; + $modifiedColumns[':p' . $index++] = '`zipcode`'; } if ($this->isColumnModified(AddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`CITY`'; + $modifiedColumns[':p' . $index++] = '`city`'; } if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`'; + $modifiedColumns[':p' . $index++] = '`country_id`'; } if ($this->isColumnModified(AddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`PHONE`'; + $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(AddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -1096,52 +1108,52 @@ abstract class BaseAddress extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`CUSTOMER_ID`': + case '`customer_id`': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case '`CUSTOMER_TITLE_ID`': + case '`customer_title_id`': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`COMPANY`': + case '`company`': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`FIRSTNAME`': + case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`LASTNAME`': + case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`ADDRESS1`': + case '`address1`': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`ADDRESS2`': + case '`address2`': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`ADDRESS3`': + case '`address3`': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`ZIPCODE`': + case '`zipcode`': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`CITY`': + case '`city`': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`COUNTRY_ID`': + case '`country_id`': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`PHONE`': + case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -1212,11 +1224,11 @@ abstract class BaseAddress extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1714,12 +1726,13 @@ abstract class BaseAddress extends BaseObject implements Persistent * Get the associated Customer object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Customer The associated Customer object. * @throws PropelException */ - public function getCustomer(PropelPDO $con = null) + public function getCustomer(PropelPDO $con = null, $doQuery = true) { - if ($this->aCustomer === null && ($this->customer_id !== null)) { + if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1765,12 +1778,13 @@ abstract class BaseAddress extends BaseObject implements Persistent * Get the associated CustomerTitle object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return CustomerTitle The associated CustomerTitle object. * @throws PropelException */ - public function getCustomerTitle(PropelPDO $con = null) + public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { + if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1807,6 +1821,7 @@ abstract class BaseAddress extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1824,7 +1839,16 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCustomer instanceof Persistent) { + $this->aCustomer->clearAllReferences($deep); + } + if ($this->aCustomerTitle instanceof Persistent) { + $this->aCustomerTitle->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCustomer = null; diff --git a/core/lib/Thelia/Model/om/BaseAddressPeer.php b/core/lib/Thelia/Model/om/BaseAddressPeer.php index 7ffed74ba..0c43808bc 100644 --- a/core/lib/Thelia/Model/om/BaseAddressPeer.php +++ b/core/lib/Thelia/Model/om/BaseAddressPeer.php @@ -46,53 +46,53 @@ abstract class BaseAddressPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 16; - /** the column name for the ID field */ - const ID = 'address.ID'; + /** the column name for the id field */ + const ID = 'address.id'; - /** the column name for the TITLE field */ - const TITLE = 'address.TITLE'; + /** the column name for the title field */ + const TITLE = 'address.title'; - /** the column name for the CUSTOMER_ID field */ - const CUSTOMER_ID = 'address.CUSTOMER_ID'; + /** the column name for the customer_id field */ + const CUSTOMER_ID = 'address.customer_id'; - /** the column name for the CUSTOMER_TITLE_ID field */ - const CUSTOMER_TITLE_ID = 'address.CUSTOMER_TITLE_ID'; + /** the column name for the customer_title_id field */ + const CUSTOMER_TITLE_ID = 'address.customer_title_id'; - /** the column name for the COMPANY field */ - const COMPANY = 'address.COMPANY'; + /** the column name for the company field */ + const COMPANY = 'address.company'; - /** the column name for the FIRSTNAME field */ - const FIRSTNAME = 'address.FIRSTNAME'; + /** the column name for the firstname field */ + const FIRSTNAME = 'address.firstname'; - /** the column name for the LASTNAME field */ - const LASTNAME = 'address.LASTNAME'; + /** the column name for the lastname field */ + const LASTNAME = 'address.lastname'; - /** the column name for the ADDRESS1 field */ - const ADDRESS1 = 'address.ADDRESS1'; + /** the column name for the address1 field */ + const ADDRESS1 = 'address.address1'; - /** the column name for the ADDRESS2 field */ - const ADDRESS2 = 'address.ADDRESS2'; + /** the column name for the address2 field */ + const ADDRESS2 = 'address.address2'; - /** the column name for the ADDRESS3 field */ - const ADDRESS3 = 'address.ADDRESS3'; + /** the column name for the address3 field */ + const ADDRESS3 = 'address.address3'; - /** the column name for the ZIPCODE field */ - const ZIPCODE = 'address.ZIPCODE'; + /** the column name for the zipcode field */ + const ZIPCODE = 'address.zipcode'; - /** the column name for the CITY field */ - const CITY = 'address.CITY'; + /** the column name for the city field */ + const CITY = 'address.city'; - /** the column name for the COUNTRY_ID field */ - const COUNTRY_ID = 'address.COUNTRY_ID'; + /** the column name for the country_id field */ + const COUNTRY_ID = 'address.country_id'; - /** the column name for the PHONE field */ - const PHONE = 'address.PHONE'; + /** the column name for the phone field */ + const PHONE = 'address.phone'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'address.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'address.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'address.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'address.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -224,22 +224,22 @@ abstract class BaseAddressPeer $criteria->addSelectColumn(AddressPeer::CREATED_AT); $criteria->addSelectColumn(AddressPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); - $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID'); - $criteria->addSelectColumn($alias . '.COMPANY'); - $criteria->addSelectColumn($alias . '.FIRSTNAME'); - $criteria->addSelectColumn($alias . '.LASTNAME'); - $criteria->addSelectColumn($alias . '.ADDRESS1'); - $criteria->addSelectColumn($alias . '.ADDRESS2'); - $criteria->addSelectColumn($alias . '.ADDRESS3'); - $criteria->addSelectColumn($alias . '.ZIPCODE'); - $criteria->addSelectColumn($alias . '.CITY'); - $criteria->addSelectColumn($alias . '.COUNTRY_ID'); - $criteria->addSelectColumn($alias . '.PHONE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.customer_id'); + $criteria->addSelectColumn($alias . '.customer_title_id'); + $criteria->addSelectColumn($alias . '.company'); + $criteria->addSelectColumn($alias . '.firstname'); + $criteria->addSelectColumn($alias . '.lastname'); + $criteria->addSelectColumn($alias . '.address1'); + $criteria->addSelectColumn($alias . '.address2'); + $criteria->addSelectColumn($alias . '.address3'); + $criteria->addSelectColumn($alias . '.zipcode'); + $criteria->addSelectColumn($alias . '.city'); + $criteria->addSelectColumn($alias . '.country_id'); + $criteria->addSelectColumn($alias . '.phone'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -323,7 +323,7 @@ abstract class BaseAddressPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -428,8 +428,15 @@ abstract class BaseAddressPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AddressPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AddressPeer::$instances = array(); } @@ -1195,7 +1202,7 @@ abstract class BaseAddressPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AddressPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/om/BaseAddressQuery.php index 4cc657dde..46b6e5146 100644 --- a/core/lib/Thelia/Model/om/BaseAddressQuery.php +++ b/core/lib/Thelia/Model/om/BaseAddressQuery.php @@ -72,7 +72,6 @@ use Thelia\Model\CustomerTitle; * @method Address findOne(PropelPDO $con = null) Return the first Address matching the query * @method Address findOneOrCreate(PropelPDO $con = null) Return the first Address matching the query, or a new Address object populated from the query conditions when no match is found * - * @method Address findOneById(int $id) Return the first Address filtered by the id column * @method Address findOneByTitle(string $title) Return the first Address filtered by the title column * @method Address findOneByCustomerId(int $customer_id) Return the first Address filtered by the customer_id column * @method Address findOneByCustomerTitleId(int $customer_title_id) Return the first Address filtered by the customer_title_id column @@ -126,7 +125,7 @@ abstract class BaseAddressQuery extends ModelCriteria * Returns a new AddressQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AddressQuery|Criteria $criteria Optional Criteria to build the query from + * @param AddressQuery|Criteria $criteria Optional Criteria to build the query from * * @return AddressQuery */ @@ -182,6 +181,20 @@ abstract class BaseAddressQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Address A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -189,12 +202,12 @@ abstract class BaseAddressQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Address A model object, or null if the key is not found - * @throws PropelException + * @return Address A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TITLE`, `CUSTOMER_ID`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `COUNTRY_ID`, `PHONE`, `CREATED_AT`, `UPDATED_AT` FROM `address` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `title`, `customer_id`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `country_id`, `phone`, `created_at`, `updated_at` FROM `address` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -290,7 +303,8 @@ abstract class BaseAddressQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -303,8 +317,22 @@ abstract class BaseAddressQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AddressPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AddressPeer::ID, $id, $comparison); @@ -346,7 +374,8 @@ abstract class BaseAddressQuery extends ModelCriteria * * $query->filterByCustomerId(1234); // WHERE customer_id = 1234 * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34) - * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12 + * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12 + * $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12 * * * @see filterByCustomer() @@ -389,7 +418,8 @@ abstract class BaseAddressQuery extends ModelCriteria * * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 + * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 * * * @see filterByCustomerTitle() @@ -664,7 +694,8 @@ abstract class BaseAddressQuery extends ModelCriteria * * $query->filterByCountryId(1234); // WHERE country_id = 1234 * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 + * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 * * * @param mixed $countryId The value to use as filter. @@ -819,8 +850,8 @@ abstract class BaseAddressQuery extends ModelCriteria * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AddressQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomer($customer, $comparison = null) { @@ -895,8 +926,8 @@ abstract class BaseAddressQuery extends ModelCriteria * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AddressQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomerTitle($customerTitle, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/om/BaseAdmin.php index 305b7aa8a..d1613291f 100644 --- a/core/lib/Thelia/Model/om/BaseAdmin.php +++ b/core/lib/Thelia/Model/om/BaseAdmin.php @@ -123,6 +123,12 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -218,22 +224,25 @@ abstract class BaseAdmin extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -255,22 +264,25 @@ abstract class BaseAdmin extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -281,7 +293,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -302,7 +314,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setFirstname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -323,7 +335,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setLastname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -344,7 +356,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setLogin($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -365,7 +377,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setPassword($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -386,7 +398,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setAlgo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -407,7 +419,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function setSalt($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -514,7 +526,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 9; // 9 = AdminPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -726,7 +738,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($this->collAdminGroups !== null) { foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -759,31 +771,31 @@ abstract class BaseAdmin extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AdminPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AdminPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`FIRSTNAME`'; + $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(AdminPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`LASTNAME`'; + $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(AdminPeer::LOGIN)) { - $modifiedColumns[':p' . $index++] = '`LOGIN`'; + $modifiedColumns[':p' . $index++] = '`login`'; } if ($this->isColumnModified(AdminPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`PASSWORD`'; + $modifiedColumns[':p' . $index++] = '`password`'; } if ($this->isColumnModified(AdminPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`ALGO`'; + $modifiedColumns[':p' . $index++] = '`algo`'; } if ($this->isColumnModified(AdminPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`SALT`'; + $modifiedColumns[':p' . $index++] = '`salt`'; } if ($this->isColumnModified(AdminPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AdminPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -796,31 +808,31 @@ abstract class BaseAdmin extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`FIRSTNAME`': + case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`LASTNAME`': + case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`LOGIN`': + case '`login`': $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR); break; - case '`PASSWORD`': + case '`password`': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; - case '`ALGO`': + case '`algo`': $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); break; - case '`SALT`': + case '`salt`': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -891,11 +903,11 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1306,13 +1318,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Admin The current object (for fluent API support) * @see addAdminGroups() */ public function clearAdminGroups() { $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized $this->collAdminGroupsPartial = null; + + return $this; } /** @@ -1384,6 +1398,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->collAdminGroupsPartial = true; } + $collAdminGroups->getInternalIterator()->rewind(); return $collAdminGroups; } @@ -1411,12 +1426,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent * * @param PropelCollection $adminGroups A Propel collection. * @param PropelPDO $con Optional connection object + * @return Admin The current object (for fluent API support) */ public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) { - $this->adminGroupsScheduledForDeletion = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); + $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - foreach ($this->adminGroupsScheduledForDeletion as $adminGroupRemoved) { + $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); + + foreach ($adminGroupsToDelete as $adminGroupRemoved) { $adminGroupRemoved->setAdmin(null); } @@ -1427,6 +1445,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->collAdminGroups = $adminGroups; $this->collAdminGroupsPartial = false; + + return $this; } /** @@ -1444,22 +1464,22 @@ abstract class BaseAdmin extends BaseObject implements Persistent if (null === $this->collAdminGroups || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAdminGroups) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAdminGroups()); - } - $query = AdminGroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAdmin($this) - ->count($con); } - } else { - return count($this->collAdminGroups); + + if($partial && !$criteria) { + return count($this->getAdminGroups()); + } + $query = AdminGroupQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAdmin($this) + ->count($con); } + + return count($this->collAdminGroups); } /** @@ -1475,7 +1495,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->initAdminGroups(); $this->collAdminGroupsPartial = true; } - if (!$this->collAdminGroups->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAdminGroup($l); } @@ -1493,6 +1513,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * @param AdminGroup $adminGroup The adminGroup object to remove. + * @return Admin The current object (for fluent API support) */ public function removeAdminGroup($adminGroup) { @@ -1505,6 +1526,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->adminGroupsScheduledForDeletion[]= $adminGroup; $adminGroup->setAdmin(null); } + + return $this; } @@ -1548,6 +1571,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1565,12 +1589,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAdminGroups) { foreach ($this->collAdminGroups as $o) { $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collAdminGroups instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseAdminGroup.php b/core/lib/Thelia/Model/om/BaseAdminGroup.php index 79c00f118..a20e693a8 100644 --- a/core/lib/Thelia/Model/om/BaseAdminGroup.php +++ b/core/lib/Thelia/Model/om/BaseAdminGroup.php @@ -103,6 +103,12 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -152,22 +158,25 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -189,22 +198,25 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -215,7 +227,7 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -236,7 +248,7 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent */ public function setGroupId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -261,7 +273,7 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent */ public function setAdminId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -368,7 +380,7 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = AdminGroupPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -620,19 +632,19 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AdminGroupPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AdminGroupPeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`GROUP_ID`'; + $modifiedColumns[':p' . $index++] = '`group_id`'; } if ($this->isColumnModified(AdminGroupPeer::ADMIN_ID)) { - $modifiedColumns[':p' . $index++] = '`ADMIN_ID`'; + $modifiedColumns[':p' . $index++] = '`admin_id`'; } if ($this->isColumnModified(AdminGroupPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -645,19 +657,19 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`GROUP_ID`': + case '`group_id`': $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); break; - case '`ADMIN_ID`': + case '`admin_id`': $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -728,11 +740,11 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1120,12 +1132,13 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent * Get the associated Group object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Group The associated Group object. * @throws PropelException */ - public function getGroup(PropelPDO $con = null) + public function getGroup(PropelPDO $con = null, $doQuery = true) { - if ($this->aGroup === null && ($this->group_id !== null)) { + if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1171,12 +1184,13 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent * Get the associated Admin object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Admin The associated Admin object. * @throws PropelException */ - public function getAdmin(PropelPDO $con = null) + public function getAdmin(PropelPDO $con = null, $doQuery = true) { - if ($this->aAdmin === null && ($this->admin_id !== null)) { + if ($this->aAdmin === null && ($this->admin_id !== null) && $doQuery) { $this->aAdmin = AdminQuery::create()->findPk($this->admin_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1202,6 +1216,7 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1219,7 +1234,16 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aGroup instanceof Persistent) { + $this->aGroup->clearAllReferences($deep); + } + if ($this->aAdmin instanceof Persistent) { + $this->aAdmin->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aGroup = null; diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php index 6488ae3ab..26c18eb8c 100644 --- a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php +++ b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php @@ -46,20 +46,20 @@ abstract class BaseAdminGroupPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'admin_group.ID'; + /** the column name for the id field */ + const ID = 'admin_group.id'; - /** the column name for the GROUP_ID field */ - const GROUP_ID = 'admin_group.GROUP_ID'; + /** the column name for the group_id field */ + const GROUP_ID = 'admin_group.group_id'; - /** the column name for the ADMIN_ID field */ - const ADMIN_ID = 'admin_group.ADMIN_ID'; + /** the column name for the admin_id field */ + const ADMIN_ID = 'admin_group.admin_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'admin_group.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'admin_group.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'admin_group.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'admin_group.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -180,11 +180,11 @@ abstract class BaseAdminGroupPeer $criteria->addSelectColumn(AdminGroupPeer::CREATED_AT); $criteria->addSelectColumn(AdminGroupPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.ADMIN_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.group_id'); + $criteria->addSelectColumn($alias . '.admin_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -268,7 +268,7 @@ abstract class BaseAdminGroupPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -373,8 +373,15 @@ abstract class BaseAdminGroupPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AdminGroupPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AdminGroupPeer::$instances = array(); } @@ -1140,7 +1147,7 @@ abstract class BaseAdminGroupPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AdminGroupPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php index 94ae9c274..1f9695bf7 100644 --- a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php @@ -50,7 +50,6 @@ use Thelia\Model\Group; * @method AdminGroup findOne(PropelPDO $con = null) Return the first AdminGroup matching the query * @method AdminGroup findOneOrCreate(PropelPDO $con = null) Return the first AdminGroup matching the query, or a new AdminGroup object populated from the query conditions when no match is found * - * @method AdminGroup findOneById(int $id) Return the first AdminGroup filtered by the id column * @method AdminGroup findOneByGroupId(int $group_id) Return the first AdminGroup filtered by the group_id column * @method AdminGroup findOneByAdminId(int $admin_id) Return the first AdminGroup filtered by the admin_id column * @method AdminGroup findOneByCreatedAt(string $created_at) Return the first AdminGroup filtered by the created_at column @@ -82,7 +81,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * Returns a new AdminGroupQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AdminGroupQuery|Criteria $criteria Optional Criteria to build the query from + * @param AdminGroupQuery|Criteria $criteria Optional Criteria to build the query from * * @return AdminGroupQuery */ @@ -138,6 +137,20 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AdminGroup A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AdminGroup A model object, or null if the key is not found - * @throws PropelException + * @return AdminGroup A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `GROUP_ID`, `ADMIN_ID`, `CREATED_AT`, `UPDATED_AT` FROM `admin_group` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `group_id`, `admin_id`, `created_at`, `updated_at` FROM `admin_group` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseAdminGroupQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AdminGroupPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AdminGroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AdminGroupPeer::ID, $id, $comparison); @@ -273,7 +301,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $query->filterByGroupId(1234); // WHERE group_id = 1234 * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 + * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 * * * @see filterByGroup() @@ -316,7 +345,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $query->filterByAdminId(1234); // WHERE admin_id = 1234 * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34) - * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12 + * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id >= 12 + * $query->filterByAdminId(array('max' => 12)); // WHERE admin_id <= 12 * * * @see filterByAdmin() @@ -444,8 +474,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * @param Group|PropelObjectCollection $group The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AdminGroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AdminGroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroup($group, $comparison = null) { @@ -520,8 +550,8 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * @param Admin|PropelObjectCollection $admin The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AdminGroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AdminGroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAdmin($admin, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAdminLog.php b/core/lib/Thelia/Model/om/BaseAdminLog.php index f4885716a..3ce64369b 100644 --- a/core/lib/Thelia/Model/om/BaseAdminLog.php +++ b/core/lib/Thelia/Model/om/BaseAdminLog.php @@ -107,6 +107,12 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -186,22 +192,25 @@ abstract class BaseAdminLog extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -223,22 +232,25 @@ abstract class BaseAdminLog extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -249,7 +261,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -270,7 +282,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setAdminLogin($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -291,7 +303,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setAdminFirstname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -312,7 +324,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setAdminLastname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -333,7 +345,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setAction($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -354,7 +366,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function setRequest($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -460,7 +472,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = AdminLogPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -685,28 +697,28 @@ abstract class BaseAdminLog extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AdminLogPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AdminLogPeer::ADMIN_LOGIN)) { - $modifiedColumns[':p' . $index++] = '`ADMIN_LOGIN`'; + $modifiedColumns[':p' . $index++] = '`admin_login`'; } if ($this->isColumnModified(AdminLogPeer::ADMIN_FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`ADMIN_FIRSTNAME`'; + $modifiedColumns[':p' . $index++] = '`admin_firstname`'; } if ($this->isColumnModified(AdminLogPeer::ADMIN_LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`ADMIN_LASTNAME`'; + $modifiedColumns[':p' . $index++] = '`admin_lastname`'; } if ($this->isColumnModified(AdminLogPeer::ACTION)) { - $modifiedColumns[':p' . $index++] = '`ACTION`'; + $modifiedColumns[':p' . $index++] = '`action`'; } if ($this->isColumnModified(AdminLogPeer::REQUEST)) { - $modifiedColumns[':p' . $index++] = '`REQUEST`'; + $modifiedColumns[':p' . $index++] = '`request`'; } if ($this->isColumnModified(AdminLogPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AdminLogPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -719,28 +731,28 @@ abstract class BaseAdminLog extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ADMIN_LOGIN`': + case '`admin_login`': $stmt->bindValue($identifier, $this->admin_login, PDO::PARAM_STR); break; - case '`ADMIN_FIRSTNAME`': + case '`admin_firstname`': $stmt->bindValue($identifier, $this->admin_firstname, PDO::PARAM_STR); break; - case '`ADMIN_LASTNAME`': + case '`admin_lastname`': $stmt->bindValue($identifier, $this->admin_lastname, PDO::PARAM_STR); break; - case '`ACTION`': + case '`action`': $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); break; - case '`REQUEST`': + case '`request`': $stmt->bindValue($identifier, $this->request, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -811,11 +823,11 @@ abstract class BaseAdminLog extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1177,6 +1189,7 @@ abstract class BaseAdminLog extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1194,7 +1207,10 @@ abstract class BaseAdminLog extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) } diff --git a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php index c4c775b06..3220eda92 100644 --- a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php +++ b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php @@ -44,29 +44,29 @@ abstract class BaseAdminLogPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'admin_log.ID'; + /** the column name for the id field */ + const ID = 'admin_log.id'; - /** the column name for the ADMIN_LOGIN field */ - const ADMIN_LOGIN = 'admin_log.ADMIN_LOGIN'; + /** the column name for the admin_login field */ + const ADMIN_LOGIN = 'admin_log.admin_login'; - /** the column name for the ADMIN_FIRSTNAME field */ - const ADMIN_FIRSTNAME = 'admin_log.ADMIN_FIRSTNAME'; + /** the column name for the admin_firstname field */ + const ADMIN_FIRSTNAME = 'admin_log.admin_firstname'; - /** the column name for the ADMIN_LASTNAME field */ - const ADMIN_LASTNAME = 'admin_log.ADMIN_LASTNAME'; + /** the column name for the admin_lastname field */ + const ADMIN_LASTNAME = 'admin_log.admin_lastname'; - /** the column name for the ACTION field */ - const ACTION = 'admin_log.ACTION'; + /** the column name for the action field */ + const ACTION = 'admin_log.action'; - /** the column name for the REQUEST field */ - const REQUEST = 'admin_log.REQUEST'; + /** the column name for the request field */ + const REQUEST = 'admin_log.request'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'admin_log.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'admin_log.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'admin_log.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'admin_log.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -190,14 +190,14 @@ abstract class BaseAdminLogPeer $criteria->addSelectColumn(AdminLogPeer::CREATED_AT); $criteria->addSelectColumn(AdminLogPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ADMIN_LOGIN'); - $criteria->addSelectColumn($alias . '.ADMIN_FIRSTNAME'); - $criteria->addSelectColumn($alias . '.ADMIN_LASTNAME'); - $criteria->addSelectColumn($alias . '.ACTION'); - $criteria->addSelectColumn($alias . '.REQUEST'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.admin_login'); + $criteria->addSelectColumn($alias . '.admin_firstname'); + $criteria->addSelectColumn($alias . '.admin_lastname'); + $criteria->addSelectColumn($alias . '.action'); + $criteria->addSelectColumn($alias . '.request'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -281,7 +281,7 @@ abstract class BaseAdminLogPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -386,8 +386,15 @@ abstract class BaseAdminLogPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AdminLogPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AdminLogPeer::$instances = array(); } @@ -522,7 +529,7 @@ abstract class BaseAdminLogPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AdminLogPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php index e2abaa1bf..00ff8548f 100644 --- a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php @@ -44,7 +44,6 @@ use Thelia\Model\AdminLogQuery; * @method AdminLog findOne(PropelPDO $con = null) Return the first AdminLog matching the query * @method AdminLog findOneOrCreate(PropelPDO $con = null) Return the first AdminLog matching the query, or a new AdminLog object populated from the query conditions when no match is found * - * @method AdminLog findOneById(int $id) Return the first AdminLog filtered by the id column * @method AdminLog findOneByAdminLogin(string $admin_login) Return the first AdminLog filtered by the admin_login column * @method AdminLog findOneByAdminFirstname(string $admin_firstname) Return the first AdminLog filtered by the admin_firstname column * @method AdminLog findOneByAdminLastname(string $admin_lastname) Return the first AdminLog filtered by the admin_lastname column @@ -82,7 +81,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * Returns a new AdminLogQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AdminLogQuery|Criteria $criteria Optional Criteria to build the query from + * @param AdminLogQuery|Criteria $criteria Optional Criteria to build the query from * * @return AdminLogQuery */ @@ -138,6 +137,20 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AdminLog A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseAdminLogQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AdminLog A model object, or null if the key is not found - * @throws PropelException + * @return AdminLog A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ADMIN_LOGIN`, `ADMIN_FIRSTNAME`, `ADMIN_LASTNAME`, `ACTION`, `REQUEST`, `CREATED_AT`, `UPDATED_AT` FROM `admin_log` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `admin_login`, `admin_firstname`, `admin_lastname`, `action`, `request`, `created_at`, `updated_at` FROM `admin_log` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseAdminLogQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AdminLogPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AdminLogPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AdminLogPeer::ID, $id, $comparison); diff --git a/core/lib/Thelia/Model/om/BaseAdminPeer.php b/core/lib/Thelia/Model/om/BaseAdminPeer.php index e134a3161..c92832ca6 100644 --- a/core/lib/Thelia/Model/om/BaseAdminPeer.php +++ b/core/lib/Thelia/Model/om/BaseAdminPeer.php @@ -45,32 +45,32 @@ abstract class BaseAdminPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 9; - /** the column name for the ID field */ - const ID = 'admin.ID'; + /** the column name for the id field */ + const ID = 'admin.id'; - /** the column name for the FIRSTNAME field */ - const FIRSTNAME = 'admin.FIRSTNAME'; + /** the column name for the firstname field */ + const FIRSTNAME = 'admin.firstname'; - /** the column name for the LASTNAME field */ - const LASTNAME = 'admin.LASTNAME'; + /** the column name for the lastname field */ + const LASTNAME = 'admin.lastname'; - /** the column name for the LOGIN field */ - const LOGIN = 'admin.LOGIN'; + /** the column name for the login field */ + const LOGIN = 'admin.login'; - /** the column name for the PASSWORD field */ - const PASSWORD = 'admin.PASSWORD'; + /** the column name for the password field */ + const PASSWORD = 'admin.password'; - /** the column name for the ALGO field */ - const ALGO = 'admin.ALGO'; + /** the column name for the algo field */ + const ALGO = 'admin.algo'; - /** the column name for the SALT field */ - const SALT = 'admin.SALT'; + /** the column name for the salt field */ + const SALT = 'admin.salt'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'admin.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'admin.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'admin.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'admin.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -195,15 +195,15 @@ abstract class BaseAdminPeer $criteria->addSelectColumn(AdminPeer::CREATED_AT); $criteria->addSelectColumn(AdminPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FIRSTNAME'); - $criteria->addSelectColumn($alias . '.LASTNAME'); - $criteria->addSelectColumn($alias . '.LOGIN'); - $criteria->addSelectColumn($alias . '.PASSWORD'); - $criteria->addSelectColumn($alias . '.ALGO'); - $criteria->addSelectColumn($alias . '.SALT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.firstname'); + $criteria->addSelectColumn($alias . '.lastname'); + $criteria->addSelectColumn($alias . '.login'); + $criteria->addSelectColumn($alias . '.password'); + $criteria->addSelectColumn($alias . '.algo'); + $criteria->addSelectColumn($alias . '.salt'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -287,7 +287,7 @@ abstract class BaseAdminPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -392,8 +392,15 @@ abstract class BaseAdminPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AdminPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AdminPeer::$instances = array(); } @@ -531,7 +538,7 @@ abstract class BaseAdminPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AdminPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/om/BaseAdminQuery.php index 00f43de6a..7c04fc880 100644 --- a/core/lib/Thelia/Model/om/BaseAdminQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminQuery.php @@ -53,7 +53,6 @@ use Thelia\Model\AdminQuery; * @method Admin findOne(PropelPDO $con = null) Return the first Admin matching the query * @method Admin findOneOrCreate(PropelPDO $con = null) Return the first Admin matching the query, or a new Admin object populated from the query conditions when no match is found * - * @method Admin findOneById(int $id) Return the first Admin filtered by the id column * @method Admin findOneByFirstname(string $firstname) Return the first Admin filtered by the firstname column * @method Admin findOneByLastname(string $lastname) Return the first Admin filtered by the lastname column * @method Admin findOneByLogin(string $login) Return the first Admin filtered by the login column @@ -93,7 +92,7 @@ abstract class BaseAdminQuery extends ModelCriteria * Returns a new AdminQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AdminQuery|Criteria $criteria Optional Criteria to build the query from + * @param AdminQuery|Criteria $criteria Optional Criteria to build the query from * * @return AdminQuery */ @@ -149,6 +148,20 @@ abstract class BaseAdminQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Admin A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -156,12 +169,12 @@ abstract class BaseAdminQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Admin A model object, or null if the key is not found - * @throws PropelException + * @return Admin A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `FIRSTNAME`, `LASTNAME`, `LOGIN`, `PASSWORD`, `ALGO`, `SALT`, `CREATED_AT`, `UPDATED_AT` FROM `admin` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `firstname`, `lastname`, `login`, `password`, `algo`, `salt`, `created_at`, `updated_at` FROM `admin` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -257,7 +270,8 @@ abstract class BaseAdminQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -270,8 +284,22 @@ abstract class BaseAdminQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AdminPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AdminPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AdminPeer::ID, $id, $comparison); @@ -543,8 +571,8 @@ abstract class BaseAdminQuery extends ModelCriteria * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AdminQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AdminQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAdminGroup($adminGroup, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseArea.php b/core/lib/Thelia/Model/om/BaseArea.php index 348cbb1dd..d1e06623b 100644 --- a/core/lib/Thelia/Model/om/BaseArea.php +++ b/core/lib/Thelia/Model/om/BaseArea.php @@ -107,6 +107,12 @@ abstract class BaseArea extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -168,22 +174,25 @@ abstract class BaseArea extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -205,22 +214,25 @@ abstract class BaseArea extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -231,7 +243,7 @@ abstract class BaseArea extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -252,7 +264,7 @@ abstract class BaseArea extends BaseObject implements Persistent */ public function setName($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -273,7 +285,7 @@ abstract class BaseArea extends BaseObject implements Persistent */ public function setUnit($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -376,7 +388,7 @@ abstract class BaseArea extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = AreaPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -590,7 +602,7 @@ abstract class BaseArea extends BaseObject implements Persistent if ($this->collCountrys !== null) { foreach ($this->collCountrys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -608,7 +620,7 @@ abstract class BaseArea extends BaseObject implements Persistent if ($this->collDelivzones !== null) { foreach ($this->collDelivzones as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -641,19 +653,19 @@ abstract class BaseArea extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AreaPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AreaPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`NAME`'; + $modifiedColumns[':p' . $index++] = '`name`'; } if ($this->isColumnModified(AreaPeer::UNIT)) { - $modifiedColumns[':p' . $index++] = '`UNIT`'; + $modifiedColumns[':p' . $index++] = '`unit`'; } if ($this->isColumnModified(AreaPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AreaPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -666,19 +678,19 @@ abstract class BaseArea extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`NAME`': + case '`name`': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case '`UNIT`': + case '`unit`': $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -749,11 +761,11 @@ abstract class BaseArea extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1144,13 +1156,15 @@ abstract class BaseArea extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Area The current object (for fluent API support) * @see addCountrys() */ public function clearCountrys() { $this->collCountrys = null; // important to set this to null since that means it is uninitialized $this->collCountrysPartial = null; + + return $this; } /** @@ -1222,6 +1236,7 @@ abstract class BaseArea extends BaseObject implements Persistent $this->collCountrysPartial = true; } + $collCountrys->getInternalIterator()->rewind(); return $collCountrys; } @@ -1249,12 +1264,15 @@ abstract class BaseArea extends BaseObject implements Persistent * * @param PropelCollection $countrys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Area The current object (for fluent API support) */ public function setCountrys(PropelCollection $countrys, PropelPDO $con = null) { - $this->countrysScheduledForDeletion = $this->getCountrys(new Criteria(), $con)->diff($countrys); + $countrysToDelete = $this->getCountrys(new Criteria(), $con)->diff($countrys); - foreach ($this->countrysScheduledForDeletion as $countryRemoved) { + $this->countrysScheduledForDeletion = unserialize(serialize($countrysToDelete)); + + foreach ($countrysToDelete as $countryRemoved) { $countryRemoved->setArea(null); } @@ -1265,6 +1283,8 @@ abstract class BaseArea extends BaseObject implements Persistent $this->collCountrys = $countrys; $this->collCountrysPartial = false; + + return $this; } /** @@ -1282,22 +1302,22 @@ abstract class BaseArea extends BaseObject implements Persistent if (null === $this->collCountrys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCountrys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCountrys()); - } - $query = CountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByArea($this) - ->count($con); } - } else { - return count($this->collCountrys); + + if($partial && !$criteria) { + return count($this->getCountrys()); + } + $query = CountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByArea($this) + ->count($con); } + + return count($this->collCountrys); } /** @@ -1313,7 +1333,7 @@ abstract class BaseArea extends BaseObject implements Persistent $this->initCountrys(); $this->collCountrysPartial = true; } - if (!$this->collCountrys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCountry($l); } @@ -1331,6 +1351,7 @@ abstract class BaseArea extends BaseObject implements Persistent /** * @param Country $country The country object to remove. + * @return Area The current object (for fluent API support) */ public function removeCountry($country) { @@ -1343,6 +1364,8 @@ abstract class BaseArea extends BaseObject implements Persistent $this->countrysScheduledForDeletion[]= $country; $country->setArea(null); } + + return $this; } /** @@ -1351,13 +1374,15 @@ abstract class BaseArea extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Area The current object (for fluent API support) * @see addDelivzones() */ public function clearDelivzones() { $this->collDelivzones = null; // important to set this to null since that means it is uninitialized $this->collDelivzonesPartial = null; + + return $this; } /** @@ -1429,6 +1454,7 @@ abstract class BaseArea extends BaseObject implements Persistent $this->collDelivzonesPartial = true; } + $collDelivzones->getInternalIterator()->rewind(); return $collDelivzones; } @@ -1456,12 +1482,15 @@ abstract class BaseArea extends BaseObject implements Persistent * * @param PropelCollection $delivzones A Propel collection. * @param PropelPDO $con Optional connection object + * @return Area The current object (for fluent API support) */ public function setDelivzones(PropelCollection $delivzones, PropelPDO $con = null) { - $this->delivzonesScheduledForDeletion = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); + $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); - foreach ($this->delivzonesScheduledForDeletion as $delivzoneRemoved) { + $this->delivzonesScheduledForDeletion = unserialize(serialize($delivzonesToDelete)); + + foreach ($delivzonesToDelete as $delivzoneRemoved) { $delivzoneRemoved->setArea(null); } @@ -1472,6 +1501,8 @@ abstract class BaseArea extends BaseObject implements Persistent $this->collDelivzones = $delivzones; $this->collDelivzonesPartial = false; + + return $this; } /** @@ -1489,22 +1520,22 @@ abstract class BaseArea extends BaseObject implements Persistent if (null === $this->collDelivzones || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDelivzones) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDelivzones()); - } - $query = DelivzoneQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByArea($this) - ->count($con); } - } else { - return count($this->collDelivzones); + + if($partial && !$criteria) { + return count($this->getDelivzones()); + } + $query = DelivzoneQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByArea($this) + ->count($con); } + + return count($this->collDelivzones); } /** @@ -1520,7 +1551,7 @@ abstract class BaseArea extends BaseObject implements Persistent $this->initDelivzones(); $this->collDelivzonesPartial = true; } - if (!$this->collDelivzones->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDelivzone($l); } @@ -1538,6 +1569,7 @@ abstract class BaseArea extends BaseObject implements Persistent /** * @param Delivzone $delivzone The delivzone object to remove. + * @return Area The current object (for fluent API support) */ public function removeDelivzone($delivzone) { @@ -1550,6 +1582,8 @@ abstract class BaseArea extends BaseObject implements Persistent $this->delivzonesScheduledForDeletion[]= $delivzone; $delivzone->setArea(null); } + + return $this; } /** @@ -1564,6 +1598,7 @@ abstract class BaseArea extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1581,7 +1616,8 @@ abstract class BaseArea extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collCountrys) { foreach ($this->collCountrys as $o) { $o->clearAllReferences($deep); @@ -1592,6 +1628,8 @@ abstract class BaseArea extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collCountrys instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseAreaPeer.php b/core/lib/Thelia/Model/om/BaseAreaPeer.php index 509b07043..b543e5ac7 100644 --- a/core/lib/Thelia/Model/om/BaseAreaPeer.php +++ b/core/lib/Thelia/Model/om/BaseAreaPeer.php @@ -46,20 +46,20 @@ abstract class BaseAreaPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'area.ID'; + /** the column name for the id field */ + const ID = 'area.id'; - /** the column name for the NAME field */ - const NAME = 'area.NAME'; + /** the column name for the name field */ + const NAME = 'area.name'; - /** the column name for the UNIT field */ - const UNIT = 'area.UNIT'; + /** the column name for the unit field */ + const UNIT = 'area.unit'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'area.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'area.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'area.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'area.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -180,11 +180,11 @@ abstract class BaseAreaPeer $criteria->addSelectColumn(AreaPeer::CREATED_AT); $criteria->addSelectColumn(AreaPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.UNIT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.unit'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -268,7 +268,7 @@ abstract class BaseAreaPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -373,8 +373,15 @@ abstract class BaseAreaPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AreaPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AreaPeer::$instances = array(); } @@ -515,7 +522,7 @@ abstract class BaseAreaPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AreaPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/om/BaseAreaQuery.php index 9270c9e55..3feaaca2f 100644 --- a/core/lib/Thelia/Model/om/BaseAreaQuery.php +++ b/core/lib/Thelia/Model/om/BaseAreaQuery.php @@ -50,7 +50,6 @@ use Thelia\Model\Delivzone; * @method Area findOne(PropelPDO $con = null) Return the first Area matching the query * @method Area findOneOrCreate(PropelPDO $con = null) Return the first Area matching the query, or a new Area object populated from the query conditions when no match is found * - * @method Area findOneById(int $id) Return the first Area filtered by the id column * @method Area findOneByName(string $name) Return the first Area filtered by the name column * @method Area findOneByUnit(double $unit) Return the first Area filtered by the unit column * @method Area findOneByCreatedAt(string $created_at) Return the first Area filtered by the created_at column @@ -82,7 +81,7 @@ abstract class BaseAreaQuery extends ModelCriteria * Returns a new AreaQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AreaQuery|Criteria $criteria Optional Criteria to build the query from + * @param AreaQuery|Criteria $criteria Optional Criteria to build the query from * * @return AreaQuery */ @@ -138,6 +137,20 @@ abstract class BaseAreaQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Area A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseAreaQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Area A model object, or null if the key is not found - * @throws PropelException + * @return Area A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `NAME`, `UNIT`, `CREATED_AT`, `UPDATED_AT` FROM `area` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `name`, `unit`, `created_at`, `updated_at` FROM `area` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseAreaQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseAreaQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AreaPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AreaPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AreaPeer::ID, $id, $comparison); @@ -302,7 +330,8 @@ abstract class BaseAreaQuery extends ModelCriteria * * $query->filterByUnit(1234); // WHERE unit = 1234 * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34) - * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12 + * $query->filterByUnit(array('min' => 12)); // WHERE unit >= 12 + * $query->filterByUnit(array('max' => 12)); // WHERE unit <= 12 * * * @param mixed $unit The value to use as filter. @@ -428,8 +457,8 @@ abstract class BaseAreaQuery extends ModelCriteria * @param Country|PropelObjectCollection $country the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AreaQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AreaQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCountry($country, $comparison = null) { @@ -502,8 +531,8 @@ abstract class BaseAreaQuery extends ModelCriteria * @param Delivzone|PropelObjectCollection $delivzone the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AreaQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AreaQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDelivzone($delivzone, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/om/BaseAttribute.php index e9c6bfad8..436edd53d 100644 --- a/core/lib/Thelia/Model/om/BaseAttribute.php +++ b/core/lib/Thelia/Model/om/BaseAttribute.php @@ -117,13 +117,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -194,22 +200,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -231,22 +240,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -257,7 +269,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -278,7 +290,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -380,7 +392,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = AttributePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -597,7 +609,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->collAttributeAvs !== null) { foreach ($this->collAttributeAvs as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -614,7 +626,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->collAttributeCombinations !== null) { foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -631,7 +643,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->collAttributeCategorys !== null) { foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -648,7 +660,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->collAttributeI18ns !== null) { foreach ($this->collAttributeI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -681,16 +693,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(AttributePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AttributePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -703,16 +715,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -783,11 +795,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1208,13 +1220,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Attribute The current object (for fluent API support) * @see addAttributeAvs() */ public function clearAttributeAvs() { $this->collAttributeAvs = null; // important to set this to null since that means it is uninitialized $this->collAttributeAvsPartial = null; + + return $this; } /** @@ -1286,6 +1300,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeAvsPartial = true; } + $collAttributeAvs->getInternalIterator()->rewind(); return $collAttributeAvs; } @@ -1313,12 +1328,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param PropelCollection $attributeAvs A Propel collection. * @param PropelPDO $con Optional connection object + * @return Attribute The current object (for fluent API support) */ public function setAttributeAvs(PropelCollection $attributeAvs, PropelPDO $con = null) { - $this->attributeAvsScheduledForDeletion = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs); + $attributeAvsToDelete = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs); - foreach ($this->attributeAvsScheduledForDeletion as $attributeAvRemoved) { + $this->attributeAvsScheduledForDeletion = unserialize(serialize($attributeAvsToDelete)); + + foreach ($attributeAvsToDelete as $attributeAvRemoved) { $attributeAvRemoved->setAttribute(null); } @@ -1329,6 +1347,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeAvs = $attributeAvs; $this->collAttributeAvsPartial = false; + + return $this; } /** @@ -1346,22 +1366,22 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null === $this->collAttributeAvs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeAvs) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeAvs()); - } - $query = AttributeAvQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); } - } else { - return count($this->collAttributeAvs); + + if($partial && !$criteria) { + return count($this->getAttributeAvs()); + } + $query = AttributeAvQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttribute($this) + ->count($con); } + + return count($this->collAttributeAvs); } /** @@ -1377,7 +1397,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->initAttributeAvs(); $this->collAttributeAvsPartial = true; } - if (!$this->collAttributeAvs->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeAv($l); } @@ -1395,6 +1415,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * @param AttributeAv $attributeAv The attributeAv object to remove. + * @return Attribute The current object (for fluent API support) */ public function removeAttributeAv($attributeAv) { @@ -1404,9 +1425,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->attributeAvsScheduledForDeletion = clone $this->collAttributeAvs; $this->attributeAvsScheduledForDeletion->clear(); } - $this->attributeAvsScheduledForDeletion[]= $attributeAv; + $this->attributeAvsScheduledForDeletion[]= clone $attributeAv; $attributeAv->setAttribute(null); } + + return $this; } /** @@ -1415,13 +1438,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Attribute The current object (for fluent API support) * @see addAttributeCombinations() */ public function clearAttributeCombinations() { $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized $this->collAttributeCombinationsPartial = null; + + return $this; } /** @@ -1493,6 +1518,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeCombinationsPartial = true; } + $collAttributeCombinations->getInternalIterator()->rewind(); return $collAttributeCombinations; } @@ -1520,12 +1546,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param PropelCollection $attributeCombinations A Propel collection. * @param PropelPDO $con Optional connection object + * @return Attribute The current object (for fluent API support) */ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) { - $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); + $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) { + $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setAttribute(null); } @@ -1536,6 +1565,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeCombinations = $attributeCombinations; $this->collAttributeCombinationsPartial = false; + + return $this; } /** @@ -1553,22 +1584,22 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeCombinations) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); } - } else { - return count($this->collAttributeCombinations); + + if($partial && !$criteria) { + return count($this->getAttributeCombinations()); + } + $query = AttributeCombinationQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttribute($this) + ->count($con); } + + return count($this->collAttributeCombinations); } /** @@ -1584,7 +1615,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->initAttributeCombinations(); $this->collAttributeCombinationsPartial = true; } - if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCombination($l); } @@ -1602,6 +1633,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return Attribute The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1611,9 +1643,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; $this->attributeCombinationsScheduledForDeletion->clear(); } - $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination; + $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; $attributeCombination->setAttribute(null); } + + return $this; } @@ -1672,13 +1706,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Attribute The current object (for fluent API support) * @see addAttributeCategorys() */ public function clearAttributeCategorys() { $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized $this->collAttributeCategorysPartial = null; + + return $this; } /** @@ -1750,6 +1786,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeCategorysPartial = true; } + $collAttributeCategorys->getInternalIterator()->rewind(); return $collAttributeCategorys; } @@ -1777,12 +1814,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param PropelCollection $attributeCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Attribute The current object (for fluent API support) */ public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) { - $this->attributeCategorysScheduledForDeletion = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); + $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - foreach ($this->attributeCategorysScheduledForDeletion as $attributeCategoryRemoved) { + $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); + + foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { $attributeCategoryRemoved->setAttribute(null); } @@ -1793,6 +1833,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeCategorys = $attributeCategorys; $this->collAttributeCategorysPartial = false; + + return $this; } /** @@ -1810,22 +1852,22 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); - } - $query = AttributeCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); } - } else { - return count($this->collAttributeCategorys); + + if($partial && !$criteria) { + return count($this->getAttributeCategorys()); + } + $query = AttributeCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttribute($this) + ->count($con); } + + return count($this->collAttributeCategorys); } /** @@ -1841,7 +1883,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->initAttributeCategorys(); $this->collAttributeCategorysPartial = true; } - if (!$this->collAttributeCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCategory($l); } @@ -1859,6 +1901,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * @param AttributeCategory $attributeCategory The attributeCategory object to remove. + * @return Attribute The current object (for fluent API support) */ public function removeAttributeCategory($attributeCategory) { @@ -1868,9 +1911,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; $this->attributeCategorysScheduledForDeletion->clear(); } - $this->attributeCategorysScheduledForDeletion[]= $attributeCategory; + $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; $attributeCategory->setAttribute(null); } + + return $this; } @@ -1904,13 +1949,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Attribute The current object (for fluent API support) * @see addAttributeI18ns() */ public function clearAttributeI18ns() { $this->collAttributeI18ns = null; // important to set this to null since that means it is uninitialized $this->collAttributeI18nsPartial = null; + + return $this; } /** @@ -1982,6 +2029,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeI18nsPartial = true; } + $collAttributeI18ns->getInternalIterator()->rewind(); return $collAttributeI18ns; } @@ -2009,12 +2057,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param PropelCollection $attributeI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Attribute The current object (for fluent API support) */ public function setAttributeI18ns(PropelCollection $attributeI18ns, PropelPDO $con = null) { - $this->attributeI18nsScheduledForDeletion = $this->getAttributeI18ns(new Criteria(), $con)->diff($attributeI18ns); + $attributeI18nsToDelete = $this->getAttributeI18ns(new Criteria(), $con)->diff($attributeI18ns); - foreach ($this->attributeI18nsScheduledForDeletion as $attributeI18nRemoved) { + $this->attributeI18nsScheduledForDeletion = unserialize(serialize($attributeI18nsToDelete)); + + foreach ($attributeI18nsToDelete as $attributeI18nRemoved) { $attributeI18nRemoved->setAttribute(null); } @@ -2025,6 +2076,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeI18ns = $attributeI18ns; $this->collAttributeI18nsPartial = false; + + return $this; } /** @@ -2042,22 +2095,22 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null === $this->collAttributeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeI18ns()); - } - $query = AttributeI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); } - } else { - return count($this->collAttributeI18ns); + + if($partial && !$criteria) { + return count($this->getAttributeI18ns()); + } + $query = AttributeI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttribute($this) + ->count($con); } + + return count($this->collAttributeI18ns); } /** @@ -2077,7 +2130,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->initAttributeI18ns(); $this->collAttributeI18nsPartial = true; } - if (!$this->collAttributeI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeI18n($l); } @@ -2095,6 +2148,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * @param AttributeI18n $attributeI18n The attributeI18n object to remove. + * @return Attribute The current object (for fluent API support) */ public function removeAttributeI18n($attributeI18n) { @@ -2104,9 +2158,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->attributeI18nsScheduledForDeletion = clone $this->collAttributeI18ns; $this->attributeI18nsScheduledForDeletion->clear(); } - $this->attributeI18nsScheduledForDeletion[]= $attributeI18n; + $this->attributeI18nsScheduledForDeletion[]= clone $attributeI18n; $attributeI18n->setAttribute(null); } + + return $this; } /** @@ -2120,6 +2176,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2137,7 +2194,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAttributeAvs) { foreach ($this->collAttributeAvs as $o) { $o->clearAllReferences($deep); @@ -2158,10 +2216,12 @@ abstract class BaseAttribute extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAttributeAvs instanceof PropelCollection) { @@ -2225,7 +2285,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @return Attribute The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2249,7 +2309,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return AttributeI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeI18ns) { @@ -2284,7 +2344,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @return Attribute The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { AttributeI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/om/BaseAttributeAv.php index d2d542cd3..c6a4301a0 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAv.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAv.php @@ -114,13 +114,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -189,22 +195,25 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -226,22 +235,25 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -252,7 +264,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -273,7 +285,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function setAttributeId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -298,7 +310,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -401,7 +413,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = AttributeAvPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -630,7 +642,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($this->collAttributeCombinations !== null) { foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -647,7 +659,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($this->collAttributeAvI18ns !== null) { foreach ($this->collAttributeAvI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -680,19 +692,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributeAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`'; + $modifiedColumns[':p' . $index++] = '`attribute_id`'; } if ($this->isColumnModified(AttributeAvPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -705,19 +717,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ATTRIBUTE_ID`': + case '`attribute_id`': $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -788,11 +800,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1205,12 +1217,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * Get the associated Attribute object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Attribute The associated Attribute object. * @throws PropelException */ - public function getAttribute(PropelPDO $con = null) + public function getAttribute(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttribute === null && ($this->attribute_id !== null)) { + if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1249,13 +1262,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return AttributeAv The current object (for fluent API support) * @see addAttributeCombinations() */ public function clearAttributeCombinations() { $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized $this->collAttributeCombinationsPartial = null; + + return $this; } /** @@ -1327,6 +1342,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->collAttributeCombinationsPartial = true; } + $collAttributeCombinations->getInternalIterator()->rewind(); return $collAttributeCombinations; } @@ -1354,12 +1370,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * @param PropelCollection $attributeCombinations A Propel collection. * @param PropelPDO $con Optional connection object + * @return AttributeAv The current object (for fluent API support) */ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) { - $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); + $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) { + $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setAttributeAv(null); } @@ -1370,6 +1389,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->collAttributeCombinations = $attributeCombinations; $this->collAttributeCombinationsPartial = false; + + return $this; } /** @@ -1387,22 +1408,22 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeCombinations) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttributeAv($this) - ->count($con); } - } else { - return count($this->collAttributeCombinations); + + if($partial && !$criteria) { + return count($this->getAttributeCombinations()); + } + $query = AttributeCombinationQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttributeAv($this) + ->count($con); } + + return count($this->collAttributeCombinations); } /** @@ -1418,7 +1439,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->initAttributeCombinations(); $this->collAttributeCombinationsPartial = true; } - if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCombination($l); } @@ -1436,6 +1457,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return AttributeAv The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1445,9 +1467,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; $this->attributeCombinationsScheduledForDeletion->clear(); } - $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination; + $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; $attributeCombination->setAttributeAv(null); } + + return $this; } @@ -1506,13 +1530,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return AttributeAv The current object (for fluent API support) * @see addAttributeAvI18ns() */ public function clearAttributeAvI18ns() { $this->collAttributeAvI18ns = null; // important to set this to null since that means it is uninitialized $this->collAttributeAvI18nsPartial = null; + + return $this; } /** @@ -1584,6 +1610,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->collAttributeAvI18nsPartial = true; } + $collAttributeAvI18ns->getInternalIterator()->rewind(); return $collAttributeAvI18ns; } @@ -1611,12 +1638,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * @param PropelCollection $attributeAvI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return AttributeAv The current object (for fluent API support) */ public function setAttributeAvI18ns(PropelCollection $attributeAvI18ns, PropelPDO $con = null) { - $this->attributeAvI18nsScheduledForDeletion = $this->getAttributeAvI18ns(new Criteria(), $con)->diff($attributeAvI18ns); + $attributeAvI18nsToDelete = $this->getAttributeAvI18ns(new Criteria(), $con)->diff($attributeAvI18ns); - foreach ($this->attributeAvI18nsScheduledForDeletion as $attributeAvI18nRemoved) { + $this->attributeAvI18nsScheduledForDeletion = unserialize(serialize($attributeAvI18nsToDelete)); + + foreach ($attributeAvI18nsToDelete as $attributeAvI18nRemoved) { $attributeAvI18nRemoved->setAttributeAv(null); } @@ -1627,6 +1657,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->collAttributeAvI18ns = $attributeAvI18ns; $this->collAttributeAvI18nsPartial = false; + + return $this; } /** @@ -1644,22 +1676,22 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeAvI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeAvI18ns()); - } - $query = AttributeAvI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttributeAv($this) - ->count($con); } - } else { - return count($this->collAttributeAvI18ns); + + if($partial && !$criteria) { + return count($this->getAttributeAvI18ns()); + } + $query = AttributeAvI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttributeAv($this) + ->count($con); } + + return count($this->collAttributeAvI18ns); } /** @@ -1679,7 +1711,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->initAttributeAvI18ns(); $this->collAttributeAvI18nsPartial = true; } - if (!$this->collAttributeAvI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeAvI18n($l); } @@ -1697,6 +1729,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to remove. + * @return AttributeAv The current object (for fluent API support) */ public function removeAttributeAvI18n($attributeAvI18n) { @@ -1706,9 +1739,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->attributeAvI18nsScheduledForDeletion = clone $this->collAttributeAvI18ns; $this->attributeAvI18nsScheduledForDeletion->clear(); } - $this->attributeAvI18nsScheduledForDeletion[]= $attributeAvI18n; + $this->attributeAvI18nsScheduledForDeletion[]= clone $attributeAvI18n; $attributeAvI18n->setAttributeAv(null); } + + return $this; } /** @@ -1723,6 +1758,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1740,7 +1776,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAttributeCombinations) { foreach ($this->collAttributeCombinations as $o) { $o->clearAllReferences($deep); @@ -1751,10 +1788,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aAttribute instanceof Persistent) { + $this->aAttribute->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAttributeCombinations instanceof PropelCollection) { @@ -1811,7 +1853,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * @return AttributeAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1835,7 +1877,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return AttributeAvI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeAvI18ns) { @@ -1870,7 +1912,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * @return AttributeAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { AttributeAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php index 8e8c655db..f4d002826 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php @@ -53,7 +53,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = AttributeAvI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributeAvI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributeAvI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(AttributeAvI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(AttributeAvI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(AttributeAvI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(AttributeAvI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent * Get the associated AttributeAv object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return AttributeAv The associated AttributeAv object. * @throws PropelException */ - public function getAttributeAv(PropelPDO $con = null) + public function getAttributeAv(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttributeAv === null && ($this->id !== null)) { + if ($this->aAttributeAv === null && ($this->id !== null) && $doQuery) { $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseAttributeAvI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aAttributeAv instanceof Persistent) { + $this->aAttributeAv->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aAttributeAv = null; diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php index f3bfb4faf..078f5a4ae 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseAttributeAvI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'attribute_av_i18n.ID'; + /** the column name for the id field */ + const ID = 'attribute_av_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'attribute_av_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'attribute_av_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'attribute_av_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'attribute_av_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'attribute_av_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'attribute_av_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'attribute_av_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'attribute_av_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'attribute_av_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'attribute_av_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseAttributeAvI18nPeer $criteria->addSelectColumn(AttributeAvI18nPeer::CHAPO); $criteria->addSelectColumn(AttributeAvI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseAttributeAvI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseAttributeAvI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributeAvI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributeAvI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseAttributeAvI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributeAvI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php index 3fc4679c0..9fce7d2e2 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseAttributeAvI18nQuery extends ModelCriteria * Returns a new AttributeAvI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeAvI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeAvI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeAvI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseAttributeAvI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AttributeAvI18n A model object, or null if the key is not found - * @throws PropelException + * @return AttributeAvI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `attribute_av_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `attribute_av_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseAttributeAvI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByAttributeAv() @@ -273,8 +274,22 @@ abstract class BaseAttributeAvI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributeAvI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeAvI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeAvI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseAttributeAvI18nQuery extends ModelCriteria * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeAvI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeAvI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeAv($attributeAv, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php index d0e40073d..ceb4a41c1 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php @@ -47,20 +47,20 @@ abstract class BaseAttributeAvPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'attribute_av.ID'; + /** the column name for the id field */ + const ID = 'attribute_av.id'; - /** the column name for the ATTRIBUTE_ID field */ - const ATTRIBUTE_ID = 'attribute_av.ATTRIBUTE_ID'; + /** the column name for the attribute_id field */ + const ATTRIBUTE_ID = 'attribute_av.attribute_id'; - /** the column name for the POSITION field */ - const POSITION = 'attribute_av.POSITION'; + /** the column name for the position field */ + const POSITION = 'attribute_av.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'attribute_av.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'attribute_av.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'attribute_av.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'attribute_av.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -80,7 +80,7 @@ abstract class BaseAttributeAvPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -188,11 +188,11 @@ abstract class BaseAttributeAvPeer $criteria->addSelectColumn(AttributeAvPeer::CREATED_AT); $criteria->addSelectColumn(AttributeAvPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.attribute_id'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -276,7 +276,7 @@ abstract class BaseAttributeAvPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -381,8 +381,15 @@ abstract class BaseAttributeAvPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributeAvPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributeAvPeer::$instances = array(); } @@ -761,7 +768,7 @@ abstract class BaseAttributeAvPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributeAvPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php index 418d0a718..83bf5d6ac 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php @@ -55,7 +55,6 @@ use Thelia\Model\AttributeCombination; * @method AttributeAv findOne(PropelPDO $con = null) Return the first AttributeAv matching the query * @method AttributeAv findOneOrCreate(PropelPDO $con = null) Return the first AttributeAv matching the query, or a new AttributeAv object populated from the query conditions when no match is found * - * @method AttributeAv findOneById(int $id) Return the first AttributeAv filtered by the id column * @method AttributeAv findOneByAttributeId(int $attribute_id) Return the first AttributeAv filtered by the attribute_id column * @method AttributeAv findOneByPosition(int $position) Return the first AttributeAv filtered by the position column * @method AttributeAv findOneByCreatedAt(string $created_at) Return the first AttributeAv filtered by the created_at column @@ -87,7 +86,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * Returns a new AttributeAvQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeAvQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeAvQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeAvQuery */ @@ -143,6 +142,20 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AttributeAv A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -150,12 +163,12 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AttributeAv A model object, or null if the key is not found - * @throws PropelException + * @return AttributeAv A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ATTRIBUTE_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_av` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `attribute_id`, `position`, `created_at`, `updated_at` FROM `attribute_av` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -251,7 +264,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -264,8 +278,22 @@ abstract class BaseAttributeAvQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributeAvPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeAvPeer::ID, $id, $comparison); @@ -278,7 +306,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 + * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 * * * @see filterByAttribute() @@ -321,7 +350,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -447,8 +477,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttribute($attribute, $comparison = null) { @@ -523,8 +553,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { @@ -597,8 +627,8 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @param AttributeAvI18n|PropelObjectCollection $attributeAvI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeAvI18n($attributeAvI18n, $comparison = null) { @@ -757,7 +787,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @return AttributeAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; @@ -775,7 +805,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @return AttributeAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -796,7 +826,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @return AttributeAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategory.php b/core/lib/Thelia/Model/om/BaseAttributeCategory.php index 9c42e2082..4245e0b83 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCategory.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCategory.php @@ -103,6 +103,12 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -152,22 +158,25 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -189,22 +198,25 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -215,7 +227,7 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -236,7 +248,7 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -261,7 +273,7 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent */ public function setAttributeId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -368,7 +380,7 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -620,19 +632,19 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributeCategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributeCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(AttributeCategoryPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`'; + $modifiedColumns[':p' . $index++] = '`attribute_id`'; } if ($this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -645,19 +657,19 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`ATTRIBUTE_ID`': + case '`attribute_id`': $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -728,11 +740,11 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1120,12 +1132,13 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1171,12 +1184,13 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent * Get the associated Attribute object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Attribute The associated Attribute object. * @throws PropelException */ - public function getAttribute(PropelPDO $con = null) + public function getAttribute(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttribute === null && ($this->attribute_id !== null)) { + if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1202,6 +1216,7 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1219,7 +1234,16 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aAttribute instanceof Persistent) { + $this->aAttribute->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCategory = null; diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php index 35b5cb7b1..118b82370 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php @@ -46,20 +46,20 @@ abstract class BaseAttributeCategoryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'attribute_category.ID'; + /** the column name for the id field */ + const ID = 'attribute_category.id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'attribute_category.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'attribute_category.category_id'; - /** the column name for the ATTRIBUTE_ID field */ - const ATTRIBUTE_ID = 'attribute_category.ATTRIBUTE_ID'; + /** the column name for the attribute_id field */ + const ATTRIBUTE_ID = 'attribute_category.attribute_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'attribute_category.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'attribute_category.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'attribute_category.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'attribute_category.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -180,11 +180,11 @@ abstract class BaseAttributeCategoryPeer $criteria->addSelectColumn(AttributeCategoryPeer::CREATED_AT); $criteria->addSelectColumn(AttributeCategoryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.attribute_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -268,7 +268,7 @@ abstract class BaseAttributeCategoryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -373,8 +373,15 @@ abstract class BaseAttributeCategoryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributeCategoryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributeCategoryPeer::$instances = array(); } @@ -1140,7 +1147,7 @@ abstract class BaseAttributeCategoryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributeCategoryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php index c795bdddd..f9deef20a 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php @@ -50,7 +50,6 @@ use Thelia\Model\Category; * @method AttributeCategory findOne(PropelPDO $con = null) Return the first AttributeCategory matching the query * @method AttributeCategory findOneOrCreate(PropelPDO $con = null) Return the first AttributeCategory matching the query, or a new AttributeCategory object populated from the query conditions when no match is found * - * @method AttributeCategory findOneById(int $id) Return the first AttributeCategory filtered by the id column * @method AttributeCategory findOneByCategoryId(int $category_id) Return the first AttributeCategory filtered by the category_id column * @method AttributeCategory findOneByAttributeId(int $attribute_id) Return the first AttributeCategory filtered by the attribute_id column * @method AttributeCategory findOneByCreatedAt(string $created_at) Return the first AttributeCategory filtered by the created_at column @@ -82,7 +81,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * Returns a new AttributeCategoryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeCategoryQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeCategoryQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeCategoryQuery */ @@ -138,6 +137,20 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AttributeCategory A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AttributeCategory A model object, or null if the key is not found - * @throws PropelException + * @return AttributeCategory A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CATEGORY_ID`, `ATTRIBUTE_ID`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_category` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `category_id`, `attribute_id`, `created_at`, `updated_at` FROM `attribute_category` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributeCategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeCategoryPeer::ID, $id, $comparison); @@ -273,7 +301,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -316,7 +345,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 + * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 * * * @see filterByAttribute() @@ -444,8 +474,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -520,8 +550,8 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttribute($attribute, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombination.php b/core/lib/Thelia/Model/om/BaseAttributeCombination.php index 562d3adce..523ff9d1e 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombination.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombination.php @@ -116,6 +116,12 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -175,22 +181,25 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -212,22 +221,25 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -238,7 +250,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -259,7 +271,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ public function setAttributeId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -284,7 +296,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ public function setCombinationId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -309,7 +321,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ public function setAttributeAvId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -417,7 +429,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -680,22 +692,22 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributeCombinationPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_ID`'; + $modifiedColumns[':p' . $index++] = '`attribute_id`'; } if ($this->isColumnModified(AttributeCombinationPeer::COMBINATION_ID)) { - $modifiedColumns[':p' . $index++] = '`COMBINATION_ID`'; + $modifiedColumns[':p' . $index++] = '`combination_id`'; } if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_AV_ID)) { - $modifiedColumns[':p' . $index++] = '`ATTRIBUTE_AV_ID`'; + $modifiedColumns[':p' . $index++] = '`attribute_av_id`'; } if ($this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -708,22 +720,22 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ATTRIBUTE_ID`': + case '`attribute_id`': $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); break; - case '`COMBINATION_ID`': + case '`combination_id`': $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT); break; - case '`ATTRIBUTE_AV_ID`': + case '`attribute_av_id`': $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -794,11 +806,11 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1218,12 +1230,13 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent * Get the associated Attribute object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Attribute The associated Attribute object. * @throws PropelException */ - public function getAttribute(PropelPDO $con = null) + public function getAttribute(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttribute === null && ($this->attribute_id !== null)) { + if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1269,12 +1282,13 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent * Get the associated AttributeAv object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return AttributeAv The associated AttributeAv object. * @throws PropelException */ - public function getAttributeAv(PropelPDO $con = null) + public function getAttributeAv(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) { + if ($this->aAttributeAv === null && ($this->attribute_av_id !== null) && $doQuery) { $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_av_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1320,12 +1334,13 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent * Get the associated Combination object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Combination The associated Combination object. * @throws PropelException */ - public function getCombination(PropelPDO $con = null) + public function getCombination(PropelPDO $con = null, $doQuery = true) { - if ($this->aCombination === null && ($this->combination_id !== null)) { + if ($this->aCombination === null && ($this->combination_id !== null) && $doQuery) { $this->aCombination = CombinationQuery::create()->findPk($this->combination_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1352,6 +1367,7 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1369,7 +1385,19 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aAttribute instanceof Persistent) { + $this->aAttribute->clearAllReferences($deep); + } + if ($this->aAttributeAv instanceof Persistent) { + $this->aAttributeAv->clearAllReferences($deep); + } + if ($this->aCombination instanceof Persistent) { + $this->aCombination->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aAttribute = null; diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php index b6baad13b..b98d542d5 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php @@ -47,23 +47,23 @@ abstract class BaseAttributeCombinationPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'attribute_combination.ID'; + /** the column name for the id field */ + const ID = 'attribute_combination.id'; - /** the column name for the ATTRIBUTE_ID field */ - const ATTRIBUTE_ID = 'attribute_combination.ATTRIBUTE_ID'; + /** the column name for the attribute_id field */ + const ATTRIBUTE_ID = 'attribute_combination.attribute_id'; - /** the column name for the COMBINATION_ID field */ - const COMBINATION_ID = 'attribute_combination.COMBINATION_ID'; + /** the column name for the combination_id field */ + const COMBINATION_ID = 'attribute_combination.combination_id'; - /** the column name for the ATTRIBUTE_AV_ID field */ - const ATTRIBUTE_AV_ID = 'attribute_combination.ATTRIBUTE_AV_ID'; + /** the column name for the attribute_av_id field */ + const ATTRIBUTE_AV_ID = 'attribute_combination.attribute_av_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'attribute_combination.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'attribute_combination.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'attribute_combination.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'attribute_combination.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -185,12 +185,12 @@ abstract class BaseAttributeCombinationPeer $criteria->addSelectColumn(AttributeCombinationPeer::CREATED_AT); $criteria->addSelectColumn(AttributeCombinationPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); - $criteria->addSelectColumn($alias . '.COMBINATION_ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.attribute_id'); + $criteria->addSelectColumn($alias . '.combination_id'); + $criteria->addSelectColumn($alias . '.attribute_av_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -274,7 +274,7 @@ abstract class BaseAttributeCombinationPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -379,8 +379,15 @@ abstract class BaseAttributeCombinationPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributeCombinationPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributeCombinationPeer::$instances = array(); } @@ -1492,7 +1499,7 @@ abstract class BaseAttributeCombinationPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributeCombinationPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php index c9f1acb1c..4366cc0bb 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php @@ -91,7 +91,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * Returns a new AttributeCombinationQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeCombinationQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeCombinationQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeCombinationQuery */ @@ -155,12 +155,12 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AttributeCombination A model object, or null if the key is not found - * @throws PropelException + * @return AttributeCombination A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ATTRIBUTE_ID`, `COMBINATION_ID`, `ATTRIBUTE_AV_ID`, `CREATED_AT`, `UPDATED_AT` FROM `attribute_combination` WHERE `ID` = :p0 AND `ATTRIBUTE_ID` = :p1 AND `COMBINATION_ID` = :p2 AND `ATTRIBUTE_AV_ID` = :p3'; + $sql = 'SELECT `id`, `attribute_id`, `combination_id`, `attribute_av_id`, `created_at`, `updated_at` FROM `attribute_combination` WHERE `id` = :p0 AND `attribute_id` = :p1 AND `combination_id` = :p2 AND `attribute_av_id` = :p3'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -276,7 +276,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -289,8 +290,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributeCombinationPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeCombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeCombinationPeer::ID, $id, $comparison); @@ -303,7 +318,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 + * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 * * * @see filterByAttribute() @@ -318,8 +334,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria */ public function filterByAttributeId($attributeId = null, $comparison = null) { - if (is_array($attributeId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($attributeId)) { + $useMinMax = false; + if (isset($attributeId['min'])) { + $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($attributeId['max'])) { + $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId, $comparison); @@ -332,7 +362,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $query->filterByCombinationId(1234); // WHERE combination_id = 1234 * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34) - * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12 + * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id >= 12 + * $query->filterByCombinationId(array('max' => 12)); // WHERE combination_id <= 12 * * * @see filterByCombination() @@ -347,8 +378,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria */ public function filterByCombinationId($combinationId = null, $comparison = null) { - if (is_array($combinationId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($combinationId)) { + $useMinMax = false; + if (isset($combinationId['min'])) { + $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($combinationId['max'])) { + $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId, $comparison); @@ -361,7 +406,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234 * $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34) - * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12 + * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id >= 12 + * $query->filterByAttributeAvId(array('max' => 12)); // WHERE attribute_av_id <= 12 * * * @see filterByAttributeAv() @@ -376,8 +422,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria */ public function filterByAttributeAvId($attributeAvId = null, $comparison = null) { - if (is_array($attributeAvId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($attributeAvId)) { + $useMinMax = false; + if (isset($attributeAvId['min'])) { + $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($attributeAvId['max'])) { + $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); @@ -475,8 +535,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeCombinationQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttribute($attribute, $comparison = null) { @@ -551,8 +611,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeCombinationQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeAv($attributeAv, $comparison = null) { @@ -627,8 +687,8 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeCombinationQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCombination($combination, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18n.php b/core/lib/Thelia/Model/om/BaseAttributeI18n.php index b6b1e4396..acdb567fe 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeI18n.php +++ b/core/lib/Thelia/Model/om/BaseAttributeI18n.php @@ -53,7 +53,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = AttributeI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AttributeI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(AttributeI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(AttributeI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(AttributeI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(AttributeI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(AttributeI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent * Get the associated Attribute object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Attribute The associated Attribute object. * @throws PropelException */ - public function getAttribute(PropelPDO $con = null) + public function getAttribute(PropelPDO $con = null, $doQuery = true) { - if ($this->aAttribute === null && ($this->id !== null)) { + if ($this->aAttribute === null && ($this->id !== null) && $doQuery) { $this->aAttribute = AttributeQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseAttributeI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aAttribute instanceof Persistent) { + $this->aAttribute->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aAttribute = null; diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php b/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php index d2f0b9da7..a26444434 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseAttributeI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'attribute_i18n.ID'; + /** the column name for the id field */ + const ID = 'attribute_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'attribute_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'attribute_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'attribute_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'attribute_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'attribute_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'attribute_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'attribute_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'attribute_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'attribute_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'attribute_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseAttributeI18nPeer $criteria->addSelectColumn(AttributeI18nPeer::CHAPO); $criteria->addSelectColumn(AttributeI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseAttributeI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseAttributeI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributeI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributeI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseAttributeI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributeI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php b/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php index 3681f91f1..f21a25d3a 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * Returns a new AttributeI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return AttributeI18n A model object, or null if the key is not found - * @throws PropelException + * @return AttributeI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `attribute_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `attribute_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByAttribute() @@ -273,8 +274,22 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributeI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributeI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttribute($attribute, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseAttributePeer.php b/core/lib/Thelia/Model/om/BaseAttributePeer.php index 994d40bcc..47f649d15 100644 --- a/core/lib/Thelia/Model/om/BaseAttributePeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributePeer.php @@ -48,17 +48,17 @@ abstract class BaseAttributePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'attribute.ID'; + /** the column name for the id field */ + const ID = 'attribute.id'; - /** the column name for the POSITION field */ - const POSITION = 'attribute.POSITION'; + /** the column name for the position field */ + const POSITION = 'attribute.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'attribute.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'attribute.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'attribute.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'attribute.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -78,7 +78,7 @@ abstract class BaseAttributePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -185,10 +185,10 @@ abstract class BaseAttributePeer $criteria->addSelectColumn(AttributePeer::CREATED_AT); $criteria->addSelectColumn(AttributePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -272,7 +272,7 @@ abstract class BaseAttributePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseAttributePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (AttributePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } AttributePeer::$instances = array(); } @@ -525,7 +532,7 @@ abstract class BaseAttributePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return AttributePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/om/BaseAttributeQuery.php index 13b1f9a59..a3bbab373 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeQuery.php @@ -58,7 +58,6 @@ use Thelia\Model\AttributeQuery; * @method Attribute findOne(PropelPDO $con = null) Return the first Attribute matching the query * @method Attribute findOneOrCreate(PropelPDO $con = null) Return the first Attribute matching the query, or a new Attribute object populated from the query conditions when no match is found * - * @method Attribute findOneById(int $id) Return the first Attribute filtered by the id column * @method Attribute findOneByPosition(int $position) Return the first Attribute filtered by the position column * @method Attribute findOneByCreatedAt(string $created_at) Return the first Attribute filtered by the created_at column * @method Attribute findOneByUpdatedAt(string $updated_at) Return the first Attribute filtered by the updated_at column @@ -88,7 +87,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * Returns a new AttributeQuery object. * * @param string $modelAlias The alias of a model in the query - * @param AttributeQuery|Criteria $criteria Optional Criteria to build the query from + * @param AttributeQuery|Criteria $criteria Optional Criteria to build the query from * * @return AttributeQuery */ @@ -144,6 +143,20 @@ abstract class BaseAttributeQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Attribute A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -151,12 +164,12 @@ abstract class BaseAttributeQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Attribute A model object, or null if the key is not found - * @throws PropelException + * @return Attribute A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `attribute` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `position`, `created_at`, `updated_at` FROM `attribute` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -252,7 +265,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -265,8 +279,22 @@ abstract class BaseAttributeQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AttributePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(AttributePeer::ID, $id, $comparison); @@ -279,7 +307,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -405,8 +434,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeAv($attributeAv, $comparison = null) { @@ -479,8 +508,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { @@ -553,8 +582,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeCategory($attributeCategory, $comparison = null) { @@ -627,8 +656,8 @@ abstract class BaseAttributeQuery extends ModelCriteria * @param AttributeI18n|PropelObjectCollection $attributeI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return AttributeQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeI18n($attributeI18n, $comparison = null) { @@ -787,7 +816,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @return AttributeQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; @@ -805,7 +834,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @return AttributeQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -826,7 +855,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @return AttributeI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php index ea819a426..468766eea 100644 --- a/core/lib/Thelia/Model/om/BaseCategory.php +++ b/core/lib/Thelia/Model/om/BaseCategory.php @@ -195,13 +195,19 @@ abstract class BaseCategory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -361,22 +367,25 @@ abstract class BaseCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -398,22 +407,25 @@ abstract class BaseCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -445,22 +457,25 @@ abstract class BaseCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -481,7 +496,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -502,7 +517,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setParent($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -523,7 +538,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setLink($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -544,7 +559,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -565,7 +580,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -632,7 +647,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -676,7 +691,7 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -742,7 +757,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 10; // 10 = CategoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -981,7 +996,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collProductCategorys !== null) { foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -998,7 +1013,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collFeatureCategorys !== null) { foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1015,7 +1030,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collAttributeCategorys !== null) { foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1033,7 +1048,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collContentAssocs !== null) { foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1051,7 +1066,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collImages !== null) { foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1069,7 +1084,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collDocuments !== null) { foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1087,7 +1102,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1104,7 +1119,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collCategoryI18ns !== null) { foreach ($this->collCategoryI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1121,7 +1136,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->collCategoryVersions !== null) { foreach ($this->collCategoryVersions as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1154,34 +1169,34 @@ abstract class BaseCategory extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CategoryPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`PARENT`'; + $modifiedColumns[':p' . $index++] = '`parent`'; } if ($this->isColumnModified(CategoryPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`LINK`'; + $modifiedColumns[':p' . $index++] = '`link`'; } if ($this->isColumnModified(CategoryPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(CategoryPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(CategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(CategoryPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -1194,34 +1209,34 @@ abstract class BaseCategory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PARENT`': + case '`parent`': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`LINK`': + case '`link`': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1292,11 +1307,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1877,13 +1892,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addProductCategorys() */ public function clearProductCategorys() { $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized $this->collProductCategorysPartial = null; + + return $this; } /** @@ -1955,6 +1972,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collProductCategorysPartial = true; } + $collProductCategorys->getInternalIterator()->rewind(); return $collProductCategorys; } @@ -1982,12 +2000,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $productCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) { - $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); - foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { + $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); + + foreach ($productCategorysToDelete as $productCategoryRemoved) { $productCategoryRemoved->setCategory(null); } @@ -1998,6 +2019,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collProductCategorys = $productCategorys; $this->collProductCategorysPartial = false; + + return $this; } /** @@ -2015,22 +2038,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collProductCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProductCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getProductCategorys()); - } - $query = ProductCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collProductCategorys); + + if($partial && !$criteria) { + return count($this->getProductCategorys()); + } + $query = ProductCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collProductCategorys); } /** @@ -2046,7 +2069,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initProductCategorys(); $this->collProductCategorysPartial = true; } - if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductCategory($l); } @@ -2064,6 +2087,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param ProductCategory $productCategory The productCategory object to remove. + * @return Category The current object (for fluent API support) */ public function removeProductCategory($productCategory) { @@ -2073,9 +2097,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; $this->productCategorysScheduledForDeletion->clear(); } - $this->productCategorysScheduledForDeletion[]= $productCategory; + $this->productCategorysScheduledForDeletion[]= clone $productCategory; $productCategory->setCategory(null); } + + return $this; } @@ -2109,13 +2135,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addFeatureCategorys() */ public function clearFeatureCategorys() { $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized $this->collFeatureCategorysPartial = null; + + return $this; } /** @@ -2187,6 +2215,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collFeatureCategorysPartial = true; } + $collFeatureCategorys->getInternalIterator()->rewind(); return $collFeatureCategorys; } @@ -2214,12 +2243,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $featureCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) { - $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); + $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); - foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) { + $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); + + foreach ($featureCategorysToDelete as $featureCategoryRemoved) { $featureCategoryRemoved->setCategory(null); } @@ -2230,6 +2262,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collFeatureCategorys = $featureCategorys; $this->collFeatureCategorysPartial = false; + + return $this; } /** @@ -2247,22 +2281,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); - } - $query = FeatureCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collFeatureCategorys); + + if($partial && !$criteria) { + return count($this->getFeatureCategorys()); + } + $query = FeatureCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collFeatureCategorys); } /** @@ -2278,7 +2312,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initFeatureCategorys(); $this->collFeatureCategorysPartial = true; } - if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureCategory($l); } @@ -2296,6 +2330,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param FeatureCategory $featureCategory The featureCategory object to remove. + * @return Category The current object (for fluent API support) */ public function removeFeatureCategory($featureCategory) { @@ -2305,9 +2340,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; $this->featureCategorysScheduledForDeletion->clear(); } - $this->featureCategorysScheduledForDeletion[]= $featureCategory; + $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; $featureCategory->setCategory(null); } + + return $this; } @@ -2341,13 +2378,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addAttributeCategorys() */ public function clearAttributeCategorys() { $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized $this->collAttributeCategorysPartial = null; + + return $this; } /** @@ -2419,6 +2458,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collAttributeCategorysPartial = true; } + $collAttributeCategorys->getInternalIterator()->rewind(); return $collAttributeCategorys; } @@ -2446,12 +2486,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $attributeCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) { - $this->attributeCategorysScheduledForDeletion = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); + $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - foreach ($this->attributeCategorysScheduledForDeletion as $attributeCategoryRemoved) { + $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); + + foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { $attributeCategoryRemoved->setCategory(null); } @@ -2462,6 +2505,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collAttributeCategorys = $attributeCategorys; $this->collAttributeCategorysPartial = false; + + return $this; } /** @@ -2479,22 +2524,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); - } - $query = AttributeCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collAttributeCategorys); + + if($partial && !$criteria) { + return count($this->getAttributeCategorys()); + } + $query = AttributeCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collAttributeCategorys); } /** @@ -2510,7 +2555,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initAttributeCategorys(); $this->collAttributeCategorysPartial = true; } - if (!$this->collAttributeCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCategory($l); } @@ -2528,6 +2573,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param AttributeCategory $attributeCategory The attributeCategory object to remove. + * @return Category The current object (for fluent API support) */ public function removeAttributeCategory($attributeCategory) { @@ -2537,9 +2583,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; $this->attributeCategorysScheduledForDeletion->clear(); } - $this->attributeCategorysScheduledForDeletion[]= $attributeCategory; + $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; $attributeCategory->setCategory(null); } + + return $this; } @@ -2573,13 +2621,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addContentAssocs() */ public function clearContentAssocs() { $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized $this->collContentAssocsPartial = null; + + return $this; } /** @@ -2651,6 +2701,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collContentAssocsPartial = true; } + $collContentAssocs->getInternalIterator()->rewind(); return $collContentAssocs; } @@ -2678,12 +2729,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $contentAssocs A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) { - $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); + $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) { + $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setCategory(null); } @@ -2694,6 +2748,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collContentAssocs = $contentAssocs; $this->collContentAssocsPartial = false; + + return $this; } /** @@ -2711,22 +2767,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collContentAssocs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentAssocs) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collContentAssocs); + + if($partial && !$criteria) { + return count($this->getContentAssocs()); + } + $query = ContentAssocQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collContentAssocs); } /** @@ -2742,7 +2798,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initContentAssocs(); $this->collContentAssocsPartial = true; } - if (!$this->collContentAssocs->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentAssoc($l); } @@ -2760,6 +2816,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return Category The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -2772,6 +2829,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->contentAssocsScheduledForDeletion[]= $contentAssoc; $contentAssoc->setCategory(null); } + + return $this; } @@ -2830,13 +2889,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addImages() */ public function clearImages() { $this->collImages = null; // important to set this to null since that means it is uninitialized $this->collImagesPartial = null; + + return $this; } /** @@ -2908,6 +2969,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collImagesPartial = true; } + $collImages->getInternalIterator()->rewind(); return $collImages; } @@ -2935,12 +2997,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $images A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setImages(PropelCollection $images, PropelPDO $con = null) { - $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); + $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - foreach ($this->imagesScheduledForDeletion as $imageRemoved) { + $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setCategory(null); } @@ -2951,6 +3016,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collImages = $images; $this->collImagesPartial = false; + + return $this; } /** @@ -2968,22 +3035,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collImages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collImages) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collImages); + + if($partial && !$criteria) { + return count($this->getImages()); + } + $query = ImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collImages); } /** @@ -2999,7 +3066,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initImages(); $this->collImagesPartial = true; } - if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddImage($l); } @@ -3017,6 +3084,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param Image $image The image object to remove. + * @return Category The current object (for fluent API support) */ public function removeImage($image) { @@ -3029,6 +3097,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->imagesScheduledForDeletion[]= $image; $image->setCategory(null); } + + return $this; } @@ -3112,13 +3182,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addDocuments() */ public function clearDocuments() { $this->collDocuments = null; // important to set this to null since that means it is uninitialized $this->collDocumentsPartial = null; + + return $this; } /** @@ -3190,6 +3262,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collDocumentsPartial = true; } + $collDocuments->getInternalIterator()->rewind(); return $collDocuments; } @@ -3217,12 +3290,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $documents A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setDocuments(PropelCollection $documents, PropelPDO $con = null) { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setCategory(null); } @@ -3233,6 +3309,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collDocuments = $documents; $this->collDocumentsPartial = false; + + return $this; } /** @@ -3250,22 +3328,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collDocuments || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocuments) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collDocuments); + + if($partial && !$criteria) { + return count($this->getDocuments()); + } + $query = DocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collDocuments); } /** @@ -3281,7 +3359,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initDocuments(); $this->collDocumentsPartial = true; } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDocument($l); } @@ -3299,6 +3377,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param Document $document The document object to remove. + * @return Category The current object (for fluent API support) */ public function removeDocument($document) { @@ -3311,6 +3390,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->documentsScheduledForDeletion[]= $document; $document->setCategory(null); } + + return $this; } @@ -3394,13 +3475,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addRewritings() */ public function clearRewritings() { $this->collRewritings = null; // important to set this to null since that means it is uninitialized $this->collRewritingsPartial = null; + + return $this; } /** @@ -3472,6 +3555,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collRewritingsPartial = true; } + $collRewritings->getInternalIterator()->rewind(); return $collRewritings; } @@ -3499,12 +3583,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $rewritings A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) { - $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings); + $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) { + $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setCategory(null); } @@ -3515,6 +3602,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collRewritings = $rewritings; $this->collRewritingsPartial = false; + + return $this; } /** @@ -3532,22 +3621,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collRewritings || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRewritings) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collRewritings); + + if($partial && !$criteria) { + return count($this->getRewritings()); + } + $query = RewritingQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collRewritings); } /** @@ -3563,7 +3652,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initRewritings(); $this->collRewritingsPartial = true; } - if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRewriting($l); } @@ -3581,6 +3670,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param Rewriting $rewriting The rewriting object to remove. + * @return Category The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -3593,6 +3683,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->rewritingsScheduledForDeletion[]= $rewriting; $rewriting->setCategory(null); } + + return $this; } @@ -3676,13 +3768,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addCategoryI18ns() */ public function clearCategoryI18ns() { $this->collCategoryI18ns = null; // important to set this to null since that means it is uninitialized $this->collCategoryI18nsPartial = null; + + return $this; } /** @@ -3754,6 +3848,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collCategoryI18nsPartial = true; } + $collCategoryI18ns->getInternalIterator()->rewind(); return $collCategoryI18ns; } @@ -3781,12 +3876,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $categoryI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setCategoryI18ns(PropelCollection $categoryI18ns, PropelPDO $con = null) { - $this->categoryI18nsScheduledForDeletion = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns); + $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns); - foreach ($this->categoryI18nsScheduledForDeletion as $categoryI18nRemoved) { + $this->categoryI18nsScheduledForDeletion = unserialize(serialize($categoryI18nsToDelete)); + + foreach ($categoryI18nsToDelete as $categoryI18nRemoved) { $categoryI18nRemoved->setCategory(null); } @@ -3797,6 +3895,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collCategoryI18ns = $categoryI18ns; $this->collCategoryI18nsPartial = false; + + return $this; } /** @@ -3814,22 +3914,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collCategoryI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCategoryI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCategoryI18ns()); - } - $query = CategoryI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collCategoryI18ns); + + if($partial && !$criteria) { + return count($this->getCategoryI18ns()); + } + $query = CategoryI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collCategoryI18ns); } /** @@ -3849,7 +3949,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initCategoryI18ns(); $this->collCategoryI18nsPartial = true; } - if (!$this->collCategoryI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCategoryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCategoryI18n($l); } @@ -3867,6 +3967,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param CategoryI18n $categoryI18n The categoryI18n object to remove. + * @return Category The current object (for fluent API support) */ public function removeCategoryI18n($categoryI18n) { @@ -3876,9 +3977,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->categoryI18nsScheduledForDeletion = clone $this->collCategoryI18ns; $this->categoryI18nsScheduledForDeletion->clear(); } - $this->categoryI18nsScheduledForDeletion[]= $categoryI18n; + $this->categoryI18nsScheduledForDeletion[]= clone $categoryI18n; $categoryI18n->setCategory(null); } + + return $this; } /** @@ -3887,13 +3990,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Category The current object (for fluent API support) * @see addCategoryVersions() */ public function clearCategoryVersions() { $this->collCategoryVersions = null; // important to set this to null since that means it is uninitialized $this->collCategoryVersionsPartial = null; + + return $this; } /** @@ -3965,6 +4070,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collCategoryVersionsPartial = true; } + $collCategoryVersions->getInternalIterator()->rewind(); return $collCategoryVersions; } @@ -3992,12 +4098,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param PropelCollection $categoryVersions A Propel collection. * @param PropelPDO $con Optional connection object + * @return Category The current object (for fluent API support) */ public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null) { - $this->categoryVersionsScheduledForDeletion = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions); + $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions); - foreach ($this->categoryVersionsScheduledForDeletion as $categoryVersionRemoved) { + $this->categoryVersionsScheduledForDeletion = unserialize(serialize($categoryVersionsToDelete)); + + foreach ($categoryVersionsToDelete as $categoryVersionRemoved) { $categoryVersionRemoved->setCategory(null); } @@ -4008,6 +4117,8 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->collCategoryVersions = $categoryVersions; $this->collCategoryVersionsPartial = false; + + return $this; } /** @@ -4025,22 +4136,22 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null === $this->collCategoryVersions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCategoryVersions) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCategoryVersions()); - } - $query = CategoryVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); } - } else { - return count($this->collCategoryVersions); + + if($partial && !$criteria) { + return count($this->getCategoryVersions()); + } + $query = CategoryVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); } + + return count($this->collCategoryVersions); } /** @@ -4056,7 +4167,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->initCategoryVersions(); $this->collCategoryVersionsPartial = true; } - if (!$this->collCategoryVersions->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCategoryVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCategoryVersion($l); } @@ -4074,6 +4185,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * @param CategoryVersion $categoryVersion The categoryVersion object to remove. + * @return Category The current object (for fluent API support) */ public function removeCategoryVersion($categoryVersion) { @@ -4083,9 +4195,11 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->categoryVersionsScheduledForDeletion = clone $this->collCategoryVersions; $this->categoryVersionsScheduledForDeletion->clear(); } - $this->categoryVersionsScheduledForDeletion[]= $categoryVersion; + $this->categoryVersionsScheduledForDeletion[]= clone $categoryVersion; $categoryVersion->setCategory(null); } + + return $this; } /** @@ -4105,6 +4219,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -4123,7 +4238,8 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collProductCategorys) { foreach ($this->collProductCategorys as $o) { $o->clearAllReferences($deep); @@ -4169,10 +4285,12 @@ abstract class BaseCategory extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProductCategorys instanceof PropelCollection) { @@ -4256,7 +4374,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @return Category The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -4280,7 +4398,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return CategoryI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryI18ns) { @@ -4315,7 +4433,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @return Category The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { CategoryI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseCategoryI18n.php b/core/lib/Thelia/Model/om/BaseCategoryI18n.php index cbf1434b6..0a609b481 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryI18n.php +++ b/core/lib/Thelia/Model/om/BaseCategoryI18n.php @@ -53,7 +53,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = CategoryI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CategoryI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CategoryI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(CategoryI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(CategoryI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(CategoryI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(CategoryI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->id !== null)) { + if ($this->aCategory === null && ($this->id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseCategoryI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCategory = null; diff --git a/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php b/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php index e3e7ff29b..c71c16bc8 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseCategoryI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'category_i18n.ID'; + /** the column name for the id field */ + const ID = 'category_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'category_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'category_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'category_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'category_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'category_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'category_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'category_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'category_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'category_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'category_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseCategoryI18nPeer $criteria->addSelectColumn(CategoryI18nPeer::CHAPO); $criteria->addSelectColumn(CategoryI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseCategoryI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseCategoryI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CategoryI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CategoryI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseCategoryI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CategoryI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php b/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php index e6c732075..50d754e67 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * Returns a new CategoryI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CategoryI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param CategoryI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return CategoryI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CategoryI18n A model object, or null if the key is not found - * @throws PropelException + * @return CategoryI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `category_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `category_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByCategory() @@ -273,8 +274,22 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CategoryI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php index 7854dab58..d2defdbf5 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseCategoryPeer.php @@ -53,35 +53,35 @@ abstract class BaseCategoryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 10; - /** the column name for the ID field */ - const ID = 'category.ID'; + /** the column name for the id field */ + const ID = 'category.id'; - /** the column name for the PARENT field */ - const PARENT = 'category.PARENT'; + /** the column name for the parent field */ + const PARENT = 'category.parent'; - /** the column name for the LINK field */ - const LINK = 'category.LINK'; + /** the column name for the link field */ + const LINK = 'category.link'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'category.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'category.visible'; - /** the column name for the POSITION field */ - const POSITION = 'category.POSITION'; + /** the column name for the position field */ + const POSITION = 'category.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'category.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'category.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'category.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'category.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'category.VERSION'; + /** the column name for the version field */ + const VERSION = 'category.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'category.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'category.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'category.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'category.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -101,7 +101,7 @@ abstract class BaseCategoryPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; // versionable behavior /** @@ -221,16 +221,16 @@ abstract class BaseCategoryPeer $criteria->addSelectColumn(CategoryPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(CategoryPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.parent'); + $criteria->addSelectColumn($alias . '.link'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -314,7 +314,7 @@ abstract class BaseCategoryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -419,8 +419,15 @@ abstract class BaseCategoryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CategoryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CategoryPeer::$instances = array(); } @@ -582,7 +589,7 @@ abstract class BaseCategoryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CategoryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php index 3b38ee90b..ee26f7226 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseCategoryQuery.php @@ -95,7 +95,6 @@ use Thelia\Model\Rewriting; * @method Category findOne(PropelPDO $con = null) Return the first Category matching the query * @method Category findOneOrCreate(PropelPDO $con = null) Return the first Category matching the query, or a new Category object populated from the query conditions when no match is found * - * @method Category findOneById(int $id) Return the first Category filtered by the id column * @method Category findOneByParent(int $parent) Return the first Category filtered by the parent column * @method Category findOneByLink(string $link) Return the first Category filtered by the link column * @method Category findOneByVisible(int $visible) Return the first Category filtered by the visible column @@ -137,7 +136,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * Returns a new CategoryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CategoryQuery|Criteria $criteria Optional Criteria to build the query from + * @param CategoryQuery|Criteria $criteria Optional Criteria to build the query from * * @return CategoryQuery */ @@ -193,6 +192,20 @@ abstract class BaseCategoryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Category A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -200,12 +213,12 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Category A model object, or null if the key is not found - * @throws PropelException + * @return Category A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `category` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `category` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -301,7 +314,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -314,8 +328,22 @@ abstract class BaseCategoryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CategoryPeer::ID, $id, $comparison); @@ -328,7 +356,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $query->filterByParent(1234); // WHERE parent = 1234 * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 + * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 * * * @param mixed $parent The value to use as filter. @@ -398,7 +427,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -439,7 +469,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -566,7 +597,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -678,8 +710,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductCategory($productCategory, $comparison = null) { @@ -752,8 +784,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureCategory($featureCategory, $comparison = null) { @@ -826,8 +858,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeCategory($attributeCategory, $comparison = null) { @@ -900,8 +932,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentAssoc($contentAssoc, $comparison = null) { @@ -974,8 +1006,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param Image|PropelObjectCollection $image the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImage($image, $comparison = null) { @@ -1048,8 +1080,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param Document|PropelObjectCollection $document the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocument($document, $comparison = null) { @@ -1122,8 +1154,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByRewriting($rewriting, $comparison = null) { @@ -1196,8 +1228,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param CategoryI18n|PropelObjectCollection $categoryI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategoryI18n($categoryI18n, $comparison = null) { @@ -1270,8 +1302,8 @@ abstract class BaseCategoryQuery extends ModelCriteria * @param CategoryVersion|PropelObjectCollection $categoryVersion the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategoryVersion($categoryVersion, $comparison = null) { @@ -1430,7 +1462,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @return CategoryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; @@ -1448,7 +1480,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @return CategoryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1469,7 +1501,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @return CategoryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersion.php b/core/lib/Thelia/Model/om/BaseCategoryVersion.php index 737121cc0..72a5028ac 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryVersion.php +++ b/core/lib/Thelia/Model/om/BaseCategoryVersion.php @@ -127,6 +127,12 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -217,22 +223,25 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -254,22 +263,25 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -301,22 +313,25 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -337,7 +352,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -362,7 +377,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setParent($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -383,7 +398,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setLink($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -404,7 +419,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -425,7 +440,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -492,7 +507,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -536,7 +551,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -602,7 +617,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 10; // 10 = CategoryVersionPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -828,34 +843,34 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CategoryVersionPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CategoryVersionPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`PARENT`'; + $modifiedColumns[':p' . $index++] = '`parent`'; } if ($this->isColumnModified(CategoryVersionPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`LINK`'; + $modifiedColumns[':p' . $index++] = '`link`'; } if ($this->isColumnModified(CategoryVersionPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(CategoryVersionPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(CategoryVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CategoryVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(CategoryVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(CategoryVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -868,34 +883,34 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PARENT`': + case '`parent`': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`LINK`': + case '`link`': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -959,11 +974,11 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1399,12 +1414,13 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->id !== null)) { + if ($this->aCategory === null && ($this->id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1435,6 +1451,7 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1453,7 +1470,13 @@ abstract class BaseCategoryVersion extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCategory = null; diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php b/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php index f8baa283e..c3534e664 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php +++ b/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php @@ -45,35 +45,35 @@ abstract class BaseCategoryVersionPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 10; - /** the column name for the ID field */ - const ID = 'category_version.ID'; + /** the column name for the id field */ + const ID = 'category_version.id'; - /** the column name for the PARENT field */ - const PARENT = 'category_version.PARENT'; + /** the column name for the parent field */ + const PARENT = 'category_version.parent'; - /** the column name for the LINK field */ - const LINK = 'category_version.LINK'; + /** the column name for the link field */ + const LINK = 'category_version.link'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'category_version.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'category_version.visible'; - /** the column name for the POSITION field */ - const POSITION = 'category_version.POSITION'; + /** the column name for the position field */ + const POSITION = 'category_version.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'category_version.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'category_version.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'category_version.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'category_version.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'category_version.VERSION'; + /** the column name for the version field */ + const VERSION = 'category_version.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'category_version.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'category_version.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'category_version.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'category_version.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -199,16 +199,16 @@ abstract class BaseCategoryVersionPeer $criteria->addSelectColumn(CategoryVersionPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(CategoryVersionPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.parent'); + $criteria->addSelectColumn($alias . '.link'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -292,7 +292,7 @@ abstract class BaseCategoryVersionPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -397,8 +397,15 @@ abstract class BaseCategoryVersionPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CategoryVersionPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CategoryVersionPeer::$instances = array(); } @@ -771,7 +778,7 @@ abstract class BaseCategoryVersionPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CategoryVersionPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php b/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php index 18e567d68..957c2ee50 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php +++ b/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php @@ -97,7 +97,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * Returns a new CategoryVersionQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CategoryVersionQuery|Criteria $criteria Optional Criteria to build the query from + * @param CategoryVersionQuery|Criteria $criteria Optional Criteria to build the query from * * @return CategoryVersionQuery */ @@ -161,12 +161,12 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CategoryVersion A model object, or null if the key is not found - * @throws PropelException + * @return CategoryVersion A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `category_version` WHERE `ID` = :p0 AND `VERSION` = :p1'; + $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `category_version` WHERE `id` = :p0 AND `version` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -274,7 +274,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByCategory() @@ -289,8 +290,22 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CategoryVersionPeer::ID, $id, $comparison); @@ -303,7 +318,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $query->filterByParent(1234); // WHERE parent = 1234 * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 + * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 * * * @param mixed $parent The value to use as filter. @@ -373,7 +389,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -414,7 +431,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -541,7 +559,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -554,8 +573,22 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria */ public function filterByVersion($version = null, $comparison = null) { - if (is_array($version) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(CategoryVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(CategoryVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CategoryVersionPeer::VERSION, $version, $comparison); @@ -639,8 +672,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CategoryVersionQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CategoryVersionQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCombination.php b/core/lib/Thelia/Model/om/BaseCombination.php index d433f1534..a05fa4e5c 100644 --- a/core/lib/Thelia/Model/om/BaseCombination.php +++ b/core/lib/Thelia/Model/om/BaseCombination.php @@ -101,6 +101,12 @@ abstract class BaseCombination extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -152,22 +158,25 @@ abstract class BaseCombination extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -189,22 +198,25 @@ abstract class BaseCombination extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -215,7 +227,7 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -236,7 +248,7 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -338,7 +350,7 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = CombinationPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -551,7 +563,7 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($this->collAttributeCombinations !== null) { foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -569,7 +581,7 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($this->collStocks !== null) { foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -602,16 +614,16 @@ abstract class BaseCombination extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CombinationPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CombinationPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(CombinationPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -624,16 +636,16 @@ abstract class BaseCombination extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -704,11 +716,11 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1089,13 +1101,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Combination The current object (for fluent API support) * @see addAttributeCombinations() */ public function clearAttributeCombinations() { $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized $this->collAttributeCombinationsPartial = null; + + return $this; } /** @@ -1167,6 +1181,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->collAttributeCombinationsPartial = true; } + $collAttributeCombinations->getInternalIterator()->rewind(); return $collAttributeCombinations; } @@ -1194,12 +1209,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * * @param PropelCollection $attributeCombinations A Propel collection. * @param PropelPDO $con Optional connection object + * @return Combination The current object (for fluent API support) */ public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) { - $this->attributeCombinationsScheduledForDeletion = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); + $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - foreach ($this->attributeCombinationsScheduledForDeletion as $attributeCombinationRemoved) { + $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setCombination(null); } @@ -1210,6 +1228,8 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->collAttributeCombinations = $attributeCombinations; $this->collAttributeCombinationsPartial = false; + + return $this; } /** @@ -1227,22 +1247,22 @@ abstract class BaseCombination extends BaseObject implements Persistent if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAttributeCombinations) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); } - } else { - return count($this->collAttributeCombinations); + + if($partial && !$criteria) { + return count($this->getAttributeCombinations()); + } + $query = AttributeCombinationQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCombination($this) + ->count($con); } + + return count($this->collAttributeCombinations); } /** @@ -1258,7 +1278,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->initAttributeCombinations(); $this->collAttributeCombinationsPartial = true; } - if (!$this->collAttributeCombinations->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCombination($l); } @@ -1276,6 +1296,7 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return Combination The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1285,9 +1306,11 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; $this->attributeCombinationsScheduledForDeletion->clear(); } - $this->attributeCombinationsScheduledForDeletion[]= $attributeCombination; + $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; $attributeCombination->setCombination(null); } + + return $this; } @@ -1346,13 +1369,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Combination The current object (for fluent API support) * @see addStocks() */ public function clearStocks() { $this->collStocks = null; // important to set this to null since that means it is uninitialized $this->collStocksPartial = null; + + return $this; } /** @@ -1424,6 +1449,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->collStocksPartial = true; } + $collStocks->getInternalIterator()->rewind(); return $collStocks; } @@ -1451,12 +1477,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * * @param PropelCollection $stocks A Propel collection. * @param PropelPDO $con Optional connection object + * @return Combination The current object (for fluent API support) */ public function setStocks(PropelCollection $stocks, PropelPDO $con = null) { - $this->stocksScheduledForDeletion = $this->getStocks(new Criteria(), $con)->diff($stocks); + $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - foreach ($this->stocksScheduledForDeletion as $stockRemoved) { + $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); + + foreach ($stocksToDelete as $stockRemoved) { $stockRemoved->setCombination(null); } @@ -1467,6 +1496,8 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->collStocks = $stocks; $this->collStocksPartial = false; + + return $this; } /** @@ -1484,22 +1515,22 @@ abstract class BaseCombination extends BaseObject implements Persistent if (null === $this->collStocks || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collStocks) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getStocks()); - } - $query = StockQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); } - } else { - return count($this->collStocks); + + if($partial && !$criteria) { + return count($this->getStocks()); + } + $query = StockQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCombination($this) + ->count($con); } + + return count($this->collStocks); } /** @@ -1515,7 +1546,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->initStocks(); $this->collStocksPartial = true; } - if (!$this->collStocks->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddStock($l); } @@ -1533,6 +1564,7 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * @param Stock $stock The stock object to remove. + * @return Combination The current object (for fluent API support) */ public function removeStock($stock) { @@ -1545,6 +1577,8 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->stocksScheduledForDeletion[]= $stock; $stock->setCombination(null); } + + return $this; } @@ -1583,6 +1617,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1600,7 +1635,8 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAttributeCombinations) { foreach ($this->collAttributeCombinations as $o) { $o->clearAllReferences($deep); @@ -1611,6 +1647,8 @@ abstract class BaseCombination extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collAttributeCombinations instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseCombinationPeer.php b/core/lib/Thelia/Model/om/BaseCombinationPeer.php index 19c0b38ba..bb2557aa9 100644 --- a/core/lib/Thelia/Model/om/BaseCombinationPeer.php +++ b/core/lib/Thelia/Model/om/BaseCombinationPeer.php @@ -46,17 +46,17 @@ abstract class BaseCombinationPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'combination.ID'; + /** the column name for the id field */ + const ID = 'combination.id'; - /** the column name for the REF field */ - const REF = 'combination.REF'; + /** the column name for the ref field */ + const REF = 'combination.ref'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'combination.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'combination.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'combination.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'combination.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -176,10 +176,10 @@ abstract class BaseCombinationPeer $criteria->addSelectColumn(CombinationPeer::CREATED_AT); $criteria->addSelectColumn(CombinationPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -263,7 +263,7 @@ abstract class BaseCombinationPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -368,8 +368,15 @@ abstract class BaseCombinationPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CombinationPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CombinationPeer::$instances = array(); } @@ -510,7 +517,7 @@ abstract class BaseCombinationPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CombinationPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/om/BaseCombinationQuery.php index 74cd3f3ca..325af53bf 100644 --- a/core/lib/Thelia/Model/om/BaseCombinationQuery.php +++ b/core/lib/Thelia/Model/om/BaseCombinationQuery.php @@ -48,7 +48,6 @@ use Thelia\Model\Stock; * @method Combination findOne(PropelPDO $con = null) Return the first Combination matching the query * @method Combination findOneOrCreate(PropelPDO $con = null) Return the first Combination matching the query, or a new Combination object populated from the query conditions when no match is found * - * @method Combination findOneById(int $id) Return the first Combination filtered by the id column * @method Combination findOneByRef(string $ref) Return the first Combination filtered by the ref column * @method Combination findOneByCreatedAt(string $created_at) Return the first Combination filtered by the created_at column * @method Combination findOneByUpdatedAt(string $updated_at) Return the first Combination filtered by the updated_at column @@ -78,7 +77,7 @@ abstract class BaseCombinationQuery extends ModelCriteria * Returns a new CombinationQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CombinationQuery|Criteria $criteria Optional Criteria to build the query from + * @param CombinationQuery|Criteria $criteria Optional Criteria to build the query from * * @return CombinationQuery */ @@ -134,6 +133,20 @@ abstract class BaseCombinationQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Combination A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -141,12 +154,12 @@ abstract class BaseCombinationQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Combination A model object, or null if the key is not found - * @throws PropelException + * @return Combination A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `REF`, `CREATED_AT`, `UPDATED_AT` FROM `combination` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `ref`, `created_at`, `updated_at` FROM `combination` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -242,7 +255,8 @@ abstract class BaseCombinationQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -255,8 +269,22 @@ abstract class BaseCombinationQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CombinationPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CombinationPeer::ID, $id, $comparison); @@ -383,8 +411,8 @@ abstract class BaseCombinationQuery extends ModelCriteria * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CombinationQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { @@ -457,8 +485,8 @@ abstract class BaseCombinationQuery extends ModelCriteria * @param Stock|PropelObjectCollection $stock the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CombinationQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByStock($stock, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/om/BaseConfig.php index f096247eb..9a9e3b851 100644 --- a/core/lib/Thelia/Model/om/BaseConfig.php +++ b/core/lib/Thelia/Model/om/BaseConfig.php @@ -113,13 +113,19 @@ abstract class BaseConfig extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -224,22 +230,25 @@ abstract class BaseConfig extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -261,22 +270,25 @@ abstract class BaseConfig extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -287,7 +299,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -308,7 +320,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function setName($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -329,7 +341,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function setValue($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -350,7 +362,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function setSecured($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -371,7 +383,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function setHidden($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -484,7 +496,7 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = ConfigPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -695,7 +707,7 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($this->collConfigI18ns !== null) { foreach ($this->collConfigI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -728,25 +740,25 @@ abstract class BaseConfig extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ConfigPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ConfigPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`NAME`'; + $modifiedColumns[':p' . $index++] = '`name`'; } if ($this->isColumnModified(ConfigPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`VALUE`'; + $modifiedColumns[':p' . $index++] = '`value`'; } if ($this->isColumnModified(ConfigPeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`SECURED`'; + $modifiedColumns[':p' . $index++] = '`secured`'; } if ($this->isColumnModified(ConfigPeer::HIDDEN)) { - $modifiedColumns[':p' . $index++] = '`HIDDEN`'; + $modifiedColumns[':p' . $index++] = '`hidden`'; } if ($this->isColumnModified(ConfigPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -759,25 +771,25 @@ abstract class BaseConfig extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`NAME`': + case '`name`': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case '`VALUE`': + case '`value`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`SECURED`': + case '`secured`': $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; - case '`HIDDEN`': + case '`hidden`': $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -848,11 +860,11 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1243,13 +1255,15 @@ abstract class BaseConfig extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Config The current object (for fluent API support) * @see addConfigI18ns() */ public function clearConfigI18ns() { $this->collConfigI18ns = null; // important to set this to null since that means it is uninitialized $this->collConfigI18nsPartial = null; + + return $this; } /** @@ -1321,6 +1335,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->collConfigI18nsPartial = true; } + $collConfigI18ns->getInternalIterator()->rewind(); return $collConfigI18ns; } @@ -1348,12 +1363,15 @@ abstract class BaseConfig extends BaseObject implements Persistent * * @param PropelCollection $configI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Config The current object (for fluent API support) */ public function setConfigI18ns(PropelCollection $configI18ns, PropelPDO $con = null) { - $this->configI18nsScheduledForDeletion = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns); + $configI18nsToDelete = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns); - foreach ($this->configI18nsScheduledForDeletion as $configI18nRemoved) { + $this->configI18nsScheduledForDeletion = unserialize(serialize($configI18nsToDelete)); + + foreach ($configI18nsToDelete as $configI18nRemoved) { $configI18nRemoved->setConfig(null); } @@ -1364,6 +1382,8 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->collConfigI18ns = $configI18ns; $this->collConfigI18nsPartial = false; + + return $this; } /** @@ -1381,22 +1401,22 @@ abstract class BaseConfig extends BaseObject implements Persistent if (null === $this->collConfigI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collConfigI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getConfigI18ns()); - } - $query = ConfigI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByConfig($this) - ->count($con); } - } else { - return count($this->collConfigI18ns); + + if($partial && !$criteria) { + return count($this->getConfigI18ns()); + } + $query = ConfigI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByConfig($this) + ->count($con); } + + return count($this->collConfigI18ns); } /** @@ -1416,7 +1436,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->initConfigI18ns(); $this->collConfigI18nsPartial = true; } - if (!$this->collConfigI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collConfigI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddConfigI18n($l); } @@ -1434,6 +1454,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * @param ConfigI18n $configI18n The configI18n object to remove. + * @return Config The current object (for fluent API support) */ public function removeConfigI18n($configI18n) { @@ -1443,9 +1464,11 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->configI18nsScheduledForDeletion = clone $this->collConfigI18ns; $this->configI18nsScheduledForDeletion->clear(); } - $this->configI18nsScheduledForDeletion[]= $configI18n; + $this->configI18nsScheduledForDeletion[]= clone $configI18n; $configI18n->setConfig(null); } + + return $this; } /** @@ -1462,6 +1485,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1480,16 +1504,19 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collConfigI18ns) { foreach ($this->collConfigI18ns as $o) { $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collConfigI18ns instanceof PropelCollection) { @@ -1541,7 +1568,7 @@ abstract class BaseConfig extends BaseObject implements Persistent * * @return Config The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1565,7 +1592,7 @@ abstract class BaseConfig extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ConfigI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collConfigI18ns) { @@ -1600,7 +1627,7 @@ abstract class BaseConfig extends BaseObject implements Persistent * * @return Config The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ConfigI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseConfigI18n.php b/core/lib/Thelia/Model/om/BaseConfigI18n.php index 52461ff38..945a9911d 100644 --- a/core/lib/Thelia/Model/om/BaseConfigI18n.php +++ b/core/lib/Thelia/Model/om/BaseConfigI18n.php @@ -53,7 +53,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ConfigI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ConfigI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ConfigI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ConfigI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ConfigI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ConfigI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ConfigI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent * Get the associated Config object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Config The associated Config object. * @throws PropelException */ - public function getConfig(PropelPDO $con = null) + public function getConfig(PropelPDO $con = null, $doQuery = true) { - if ($this->aConfig === null && ($this->id !== null)) { + if ($this->aConfig === null && ($this->id !== null) && $doQuery) { $this->aConfig = ConfigQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseConfigI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aConfig instanceof Persistent) { + $this->aConfig->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aConfig = null; diff --git a/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php b/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php index 60ab73730..b1865513f 100644 --- a/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseConfigI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'config_i18n.ID'; + /** the column name for the id field */ + const ID = 'config_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'config_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'config_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'config_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'config_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'config_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'config_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'config_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'config_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'config_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'config_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseConfigI18nPeer $criteria->addSelectColumn(ConfigI18nPeer::CHAPO); $criteria->addSelectColumn(ConfigI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseConfigI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseConfigI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ConfigI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ConfigI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseConfigI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ConfigI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php b/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php index 4d61c7189..f53cc2de2 100644 --- a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * Returns a new ConfigI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ConfigI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ConfigI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ConfigI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ConfigI18n A model object, or null if the key is not found - * @throws PropelException + * @return ConfigI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `config_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `config_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByConfig() @@ -273,8 +274,22 @@ abstract class BaseConfigI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ConfigI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ConfigI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ConfigI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * @param Config|PropelObjectCollection $config The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ConfigI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ConfigI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByConfig($config, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseConfigPeer.php b/core/lib/Thelia/Model/om/BaseConfigPeer.php index 7fe75b370..0981b9523 100644 --- a/core/lib/Thelia/Model/om/BaseConfigPeer.php +++ b/core/lib/Thelia/Model/om/BaseConfigPeer.php @@ -45,26 +45,26 @@ abstract class BaseConfigPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'config.ID'; + /** the column name for the id field */ + const ID = 'config.id'; - /** the column name for the NAME field */ - const NAME = 'config.NAME'; + /** the column name for the name field */ + const NAME = 'config.name'; - /** the column name for the VALUE field */ - const VALUE = 'config.VALUE'; + /** the column name for the value field */ + const VALUE = 'config.value'; - /** the column name for the SECURED field */ - const SECURED = 'config.SECURED'; + /** the column name for the secured field */ + const SECURED = 'config.secured'; - /** the column name for the HIDDEN field */ - const HIDDEN = 'config.HIDDEN'; + /** the column name for the hidden field */ + const HIDDEN = 'config.hidden'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'config.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'config.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'config.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'config.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -84,7 +84,7 @@ abstract class BaseConfigPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -194,13 +194,13 @@ abstract class BaseConfigPeer $criteria->addSelectColumn(ConfigPeer::CREATED_AT); $criteria->addSelectColumn(ConfigPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.SECURED'); - $criteria->addSelectColumn($alias . '.HIDDEN'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.secured'); + $criteria->addSelectColumn($alias . '.hidden'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -284,7 +284,7 @@ abstract class BaseConfigPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -389,8 +389,15 @@ abstract class BaseConfigPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ConfigPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ConfigPeer::$instances = array(); } @@ -528,7 +535,7 @@ abstract class BaseConfigPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ConfigPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/om/BaseConfigQuery.php index a39b03dcb..808e6e5bd 100644 --- a/core/lib/Thelia/Model/om/BaseConfigQuery.php +++ b/core/lib/Thelia/Model/om/BaseConfigQuery.php @@ -49,7 +49,6 @@ use Thelia\Model\ConfigQuery; * @method Config findOne(PropelPDO $con = null) Return the first Config matching the query * @method Config findOneOrCreate(PropelPDO $con = null) Return the first Config matching the query, or a new Config object populated from the query conditions when no match is found * - * @method Config findOneById(int $id) Return the first Config filtered by the id column * @method Config findOneByName(string $name) Return the first Config filtered by the name column * @method Config findOneByValue(string $value) Return the first Config filtered by the value column * @method Config findOneBySecured(int $secured) Return the first Config filtered by the secured column @@ -85,7 +84,7 @@ abstract class BaseConfigQuery extends ModelCriteria * Returns a new ConfigQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ConfigQuery|Criteria $criteria Optional Criteria to build the query from + * @param ConfigQuery|Criteria $criteria Optional Criteria to build the query from * * @return ConfigQuery */ @@ -141,6 +140,20 @@ abstract class BaseConfigQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Config A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -148,12 +161,12 @@ abstract class BaseConfigQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Config A model object, or null if the key is not found - * @throws PropelException + * @return Config A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `NAME`, `VALUE`, `SECURED`, `HIDDEN`, `CREATED_AT`, `UPDATED_AT` FROM `config` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `name`, `value`, `secured`, `hidden`, `created_at`, `updated_at` FROM `config` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -249,7 +262,8 @@ abstract class BaseConfigQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -262,8 +276,22 @@ abstract class BaseConfigQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ConfigPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ConfigPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ConfigPeer::ID, $id, $comparison); @@ -334,7 +362,8 @@ abstract class BaseConfigQuery extends ModelCriteria * * $query->filterBySecured(1234); // WHERE secured = 1234 * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34) - * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 + * $query->filterBySecured(array('min' => 12)); // WHERE secured >= 12 + * $query->filterBySecured(array('max' => 12)); // WHERE secured <= 12 * * * @param mixed $secured The value to use as filter. @@ -375,7 +404,8 @@ abstract class BaseConfigQuery extends ModelCriteria * * $query->filterByHidden(1234); // WHERE hidden = 1234 * $query->filterByHidden(array(12, 34)); // WHERE hidden IN (12, 34) - * $query->filterByHidden(array('min' => 12)); // WHERE hidden > 12 + * $query->filterByHidden(array('min' => 12)); // WHERE hidden >= 12 + * $query->filterByHidden(array('max' => 12)); // WHERE hidden <= 12 * * * @param mixed $hidden The value to use as filter. @@ -501,8 +531,8 @@ abstract class BaseConfigQuery extends ModelCriteria * @param ConfigI18n|PropelObjectCollection $configI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ConfigQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ConfigQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByConfigI18n($configI18n, $comparison = null) { @@ -661,7 +691,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * @return ConfigQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; @@ -679,7 +709,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * @return ConfigQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -700,7 +730,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * @return ConfigI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php index 25d4e5127..ab9d27612 100644 --- a/core/lib/Thelia/Model/om/BaseContent.php +++ b/core/lib/Thelia/Model/om/BaseContent.php @@ -167,13 +167,19 @@ abstract class BaseContent extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -301,22 +307,25 @@ abstract class BaseContent extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -338,22 +347,25 @@ abstract class BaseContent extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -385,22 +397,25 @@ abstract class BaseContent extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -421,7 +436,7 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -442,7 +457,7 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -463,7 +478,7 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -530,7 +545,7 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -574,7 +589,7 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -638,7 +653,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = ContentPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -874,7 +889,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collContentAssocs !== null) { foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -892,7 +907,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collImages !== null) { foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -910,7 +925,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collDocuments !== null) { foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -928,7 +943,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -945,7 +960,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collContentFolders !== null) { foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -962,7 +977,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collContentI18ns !== null) { foreach ($this->collContentI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -979,7 +994,7 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->collContentVersions !== null) { foreach ($this->collContentVersions as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1012,28 +1027,28 @@ abstract class BaseContent extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ContentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ContentPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(ContentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ContentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ContentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(ContentPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -1046,28 +1061,28 @@ abstract class BaseContent extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1138,11 +1153,11 @@ abstract class BaseContent extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1663,13 +1678,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addContentAssocs() */ public function clearContentAssocs() { $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized $this->collContentAssocsPartial = null; + + return $this; } /** @@ -1741,6 +1758,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentAssocsPartial = true; } + $collContentAssocs->getInternalIterator()->rewind(); return $collContentAssocs; } @@ -1768,12 +1786,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $contentAssocs A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) { - $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); + $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) { + $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setContent(null); } @@ -1784,6 +1805,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentAssocs = $contentAssocs; $this->collContentAssocsPartial = false; + + return $this; } /** @@ -1801,22 +1824,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collContentAssocs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentAssocs) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collContentAssocs); + + if($partial && !$criteria) { + return count($this->getContentAssocs()); + } + $query = ContentAssocQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collContentAssocs); } /** @@ -1832,7 +1855,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initContentAssocs(); $this->collContentAssocsPartial = true; } - if (!$this->collContentAssocs->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentAssoc($l); } @@ -1850,6 +1873,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return Content The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -1862,6 +1886,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->contentAssocsScheduledForDeletion[]= $contentAssoc; $contentAssoc->setContent(null); } + + return $this; } @@ -1920,13 +1946,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addImages() */ public function clearImages() { $this->collImages = null; // important to set this to null since that means it is uninitialized $this->collImagesPartial = null; + + return $this; } /** @@ -1998,6 +2026,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collImagesPartial = true; } + $collImages->getInternalIterator()->rewind(); return $collImages; } @@ -2025,12 +2054,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $images A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setImages(PropelCollection $images, PropelPDO $con = null) { - $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); + $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - foreach ($this->imagesScheduledForDeletion as $imageRemoved) { + $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setContent(null); } @@ -2041,6 +2073,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collImages = $images; $this->collImagesPartial = false; + + return $this; } /** @@ -2058,22 +2092,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collImages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collImages) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collImages); + + if($partial && !$criteria) { + return count($this->getImages()); + } + $query = ImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collImages); } /** @@ -2089,7 +2123,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initImages(); $this->collImagesPartial = true; } - if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddImage($l); } @@ -2107,6 +2141,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param Image $image The image object to remove. + * @return Content The current object (for fluent API support) */ public function removeImage($image) { @@ -2119,6 +2154,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->imagesScheduledForDeletion[]= $image; $image->setContent(null); } + + return $this; } @@ -2202,13 +2239,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addDocuments() */ public function clearDocuments() { $this->collDocuments = null; // important to set this to null since that means it is uninitialized $this->collDocumentsPartial = null; + + return $this; } /** @@ -2280,6 +2319,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collDocumentsPartial = true; } + $collDocuments->getInternalIterator()->rewind(); return $collDocuments; } @@ -2307,12 +2347,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $documents A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setDocuments(PropelCollection $documents, PropelPDO $con = null) { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setContent(null); } @@ -2323,6 +2366,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collDocuments = $documents; $this->collDocumentsPartial = false; + + return $this; } /** @@ -2340,22 +2385,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collDocuments || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocuments) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collDocuments); + + if($partial && !$criteria) { + return count($this->getDocuments()); + } + $query = DocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collDocuments); } /** @@ -2371,7 +2416,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initDocuments(); $this->collDocumentsPartial = true; } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDocument($l); } @@ -2389,6 +2434,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param Document $document The document object to remove. + * @return Content The current object (for fluent API support) */ public function removeDocument($document) { @@ -2401,6 +2447,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->documentsScheduledForDeletion[]= $document; $document->setContent(null); } + + return $this; } @@ -2484,13 +2532,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addRewritings() */ public function clearRewritings() { $this->collRewritings = null; // important to set this to null since that means it is uninitialized $this->collRewritingsPartial = null; + + return $this; } /** @@ -2562,6 +2612,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collRewritingsPartial = true; } + $collRewritings->getInternalIterator()->rewind(); return $collRewritings; } @@ -2589,12 +2640,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $rewritings A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) { - $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings); + $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) { + $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setContent(null); } @@ -2605,6 +2659,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collRewritings = $rewritings; $this->collRewritingsPartial = false; + + return $this; } /** @@ -2622,22 +2678,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collRewritings || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRewritings) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collRewritings); + + if($partial && !$criteria) { + return count($this->getRewritings()); + } + $query = RewritingQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collRewritings); } /** @@ -2653,7 +2709,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initRewritings(); $this->collRewritingsPartial = true; } - if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRewriting($l); } @@ -2671,6 +2727,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param Rewriting $rewriting The rewriting object to remove. + * @return Content The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -2683,6 +2740,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->rewritingsScheduledForDeletion[]= $rewriting; $rewriting->setContent(null); } + + return $this; } @@ -2766,13 +2825,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addContentFolders() */ public function clearContentFolders() { $this->collContentFolders = null; // important to set this to null since that means it is uninitialized $this->collContentFoldersPartial = null; + + return $this; } /** @@ -2844,6 +2905,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentFoldersPartial = true; } + $collContentFolders->getInternalIterator()->rewind(); return $collContentFolders; } @@ -2871,12 +2933,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $contentFolders A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) { - $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); + $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { + $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); + + foreach ($contentFoldersToDelete as $contentFolderRemoved) { $contentFolderRemoved->setContent(null); } @@ -2887,6 +2952,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentFolders = $contentFolders; $this->collContentFoldersPartial = false; + + return $this; } /** @@ -2904,22 +2971,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collContentFolders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentFolders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentFolders()); - } - $query = ContentFolderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collContentFolders); + + if($partial && !$criteria) { + return count($this->getContentFolders()); + } + $query = ContentFolderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collContentFolders); } /** @@ -2935,7 +3002,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initContentFolders(); $this->collContentFoldersPartial = true; } - if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentFolder($l); } @@ -2953,6 +3020,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param ContentFolder $contentFolder The contentFolder object to remove. + * @return Content The current object (for fluent API support) */ public function removeContentFolder($contentFolder) { @@ -2962,9 +3030,11 @@ abstract class BaseContent extends BaseObject implements Persistent $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; $this->contentFoldersScheduledForDeletion->clear(); } - $this->contentFoldersScheduledForDeletion[]= $contentFolder; + $this->contentFoldersScheduledForDeletion[]= clone $contentFolder; $contentFolder->setContent(null); } + + return $this; } @@ -2998,13 +3068,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addContentI18ns() */ public function clearContentI18ns() { $this->collContentI18ns = null; // important to set this to null since that means it is uninitialized $this->collContentI18nsPartial = null; + + return $this; } /** @@ -3076,6 +3148,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentI18nsPartial = true; } + $collContentI18ns->getInternalIterator()->rewind(); return $collContentI18ns; } @@ -3103,12 +3176,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $contentI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setContentI18ns(PropelCollection $contentI18ns, PropelPDO $con = null) { - $this->contentI18nsScheduledForDeletion = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns); + $contentI18nsToDelete = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns); - foreach ($this->contentI18nsScheduledForDeletion as $contentI18nRemoved) { + $this->contentI18nsScheduledForDeletion = unserialize(serialize($contentI18nsToDelete)); + + foreach ($contentI18nsToDelete as $contentI18nRemoved) { $contentI18nRemoved->setContent(null); } @@ -3119,6 +3195,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentI18ns = $contentI18ns; $this->collContentI18nsPartial = false; + + return $this; } /** @@ -3136,22 +3214,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collContentI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentI18ns()); - } - $query = ContentI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collContentI18ns); + + if($partial && !$criteria) { + return count($this->getContentI18ns()); + } + $query = ContentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collContentI18ns); } /** @@ -3171,7 +3249,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initContentI18ns(); $this->collContentI18nsPartial = true; } - if (!$this->collContentI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentI18n($l); } @@ -3189,6 +3267,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param ContentI18n $contentI18n The contentI18n object to remove. + * @return Content The current object (for fluent API support) */ public function removeContentI18n($contentI18n) { @@ -3198,9 +3277,11 @@ abstract class BaseContent extends BaseObject implements Persistent $this->contentI18nsScheduledForDeletion = clone $this->collContentI18ns; $this->contentI18nsScheduledForDeletion->clear(); } - $this->contentI18nsScheduledForDeletion[]= $contentI18n; + $this->contentI18nsScheduledForDeletion[]= clone $contentI18n; $contentI18n->setContent(null); } + + return $this; } /** @@ -3209,13 +3290,15 @@ abstract class BaseContent extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Content The current object (for fluent API support) * @see addContentVersions() */ public function clearContentVersions() { $this->collContentVersions = null; // important to set this to null since that means it is uninitialized $this->collContentVersionsPartial = null; + + return $this; } /** @@ -3287,6 +3370,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentVersionsPartial = true; } + $collContentVersions->getInternalIterator()->rewind(); return $collContentVersions; } @@ -3314,12 +3398,15 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param PropelCollection $contentVersions A Propel collection. * @param PropelPDO $con Optional connection object + * @return Content The current object (for fluent API support) */ public function setContentVersions(PropelCollection $contentVersions, PropelPDO $con = null) { - $this->contentVersionsScheduledForDeletion = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions); + $contentVersionsToDelete = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions); - foreach ($this->contentVersionsScheduledForDeletion as $contentVersionRemoved) { + $this->contentVersionsScheduledForDeletion = unserialize(serialize($contentVersionsToDelete)); + + foreach ($contentVersionsToDelete as $contentVersionRemoved) { $contentVersionRemoved->setContent(null); } @@ -3330,6 +3417,8 @@ abstract class BaseContent extends BaseObject implements Persistent $this->collContentVersions = $contentVersions; $this->collContentVersionsPartial = false; + + return $this; } /** @@ -3347,22 +3436,22 @@ abstract class BaseContent extends BaseObject implements Persistent if (null === $this->collContentVersions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentVersions) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentVersions()); - } - $query = ContentVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); } - } else { - return count($this->collContentVersions); + + if($partial && !$criteria) { + return count($this->getContentVersions()); + } + $query = ContentVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); } + + return count($this->collContentVersions); } /** @@ -3378,7 +3467,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->initContentVersions(); $this->collContentVersionsPartial = true; } - if (!$this->collContentVersions->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentVersion($l); } @@ -3396,6 +3485,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * @param ContentVersion $contentVersion The contentVersion object to remove. + * @return Content The current object (for fluent API support) */ public function removeContentVersion($contentVersion) { @@ -3405,9 +3495,11 @@ abstract class BaseContent extends BaseObject implements Persistent $this->contentVersionsScheduledForDeletion = clone $this->collContentVersions; $this->contentVersionsScheduledForDeletion->clear(); } - $this->contentVersionsScheduledForDeletion[]= $contentVersion; + $this->contentVersionsScheduledForDeletion[]= clone $contentVersion; $contentVersion->setContent(null); } + + return $this; } /** @@ -3425,6 +3517,7 @@ abstract class BaseContent extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -3443,7 +3536,8 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collContentAssocs) { foreach ($this->collContentAssocs as $o) { $o->clearAllReferences($deep); @@ -3479,10 +3573,12 @@ abstract class BaseContent extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collContentAssocs instanceof PropelCollection) { @@ -3558,7 +3654,7 @@ abstract class BaseContent extends BaseObject implements Persistent * * @return Content The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -3582,7 +3678,7 @@ abstract class BaseContent extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ContentI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentI18ns) { @@ -3617,7 +3713,7 @@ abstract class BaseContent extends BaseObject implements Persistent * * @return Content The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ContentI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseContentAssoc.php b/core/lib/Thelia/Model/om/BaseContentAssoc.php index f13919b72..e661951a8 100644 --- a/core/lib/Thelia/Model/om/BaseContentAssoc.php +++ b/core/lib/Thelia/Model/om/BaseContentAssoc.php @@ -122,6 +122,12 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -191,22 +197,25 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -228,22 +237,25 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -254,7 +266,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -275,7 +287,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -300,7 +312,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -325,7 +337,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function setContentId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -350,7 +362,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -455,7 +467,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = ContentAssocPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -718,25 +730,25 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ContentAssocPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ContentAssocPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(ContentAssocPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(ContentAssocPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`CONTENT_ID`'; + $modifiedColumns[':p' . $index++] = '`content_id`'; } if ($this->isColumnModified(ContentAssocPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ContentAssocPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -749,25 +761,25 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`CONTENT_ID`': + case '`content_id`': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -838,11 +850,11 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1259,12 +1271,13 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1310,12 +1323,13 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1361,12 +1375,13 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->content_id !== null)) { + if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1394,6 +1409,7 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1411,7 +1427,19 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCategory = null; diff --git a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php index 637af73d2..646dd4003 100644 --- a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php @@ -47,26 +47,26 @@ abstract class BaseContentAssocPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'content_assoc.ID'; + /** the column name for the id field */ + const ID = 'content_assoc.id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'content_assoc.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'content_assoc.category_id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'content_assoc.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'content_assoc.product_id'; - /** the column name for the CONTENT_ID field */ - const CONTENT_ID = 'content_assoc.CONTENT_ID'; + /** the column name for the content_id field */ + const CONTENT_ID = 'content_assoc.content_id'; - /** the column name for the POSITION field */ - const POSITION = 'content_assoc.POSITION'; + /** the column name for the position field */ + const POSITION = 'content_assoc.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'content_assoc.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'content_assoc.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'content_assoc.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'content_assoc.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -189,13 +189,13 @@ abstract class BaseContentAssocPeer $criteria->addSelectColumn(ContentAssocPeer::CREATED_AT); $criteria->addSelectColumn(ContentAssocPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.content_id'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -279,7 +279,7 @@ abstract class BaseContentAssocPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -384,8 +384,15 @@ abstract class BaseContentAssocPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ContentAssocPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ContentAssocPeer::$instances = array(); } @@ -1497,7 +1504,7 @@ abstract class BaseContentAssocPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ContentAssocPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php index cad72948c..709046cf2 100644 --- a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php @@ -59,7 +59,6 @@ use Thelia\Model\Product; * @method ContentAssoc findOne(PropelPDO $con = null) Return the first ContentAssoc matching the query * @method ContentAssoc findOneOrCreate(PropelPDO $con = null) Return the first ContentAssoc matching the query, or a new ContentAssoc object populated from the query conditions when no match is found * - * @method ContentAssoc findOneById(int $id) Return the first ContentAssoc filtered by the id column * @method ContentAssoc findOneByCategoryId(int $category_id) Return the first ContentAssoc filtered by the category_id column * @method ContentAssoc findOneByProductId(int $product_id) Return the first ContentAssoc filtered by the product_id column * @method ContentAssoc findOneByContentId(int $content_id) Return the first ContentAssoc filtered by the content_id column @@ -95,7 +94,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * Returns a new ContentAssocQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ContentAssocQuery|Criteria $criteria Optional Criteria to build the query from + * @param ContentAssocQuery|Criteria $criteria Optional Criteria to build the query from * * @return ContentAssocQuery */ @@ -151,6 +150,20 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return ContentAssoc A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -158,12 +171,12 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ContentAssoc A model object, or null if the key is not found - * @throws PropelException + * @return ContentAssoc A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CATEGORY_ID`, `PRODUCT_ID`, `CONTENT_ID`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `content_assoc` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `category_id`, `product_id`, `content_id`, `position`, `created_at`, `updated_at` FROM `content_assoc` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -259,7 +272,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -272,8 +286,22 @@ abstract class BaseContentAssocQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentAssocPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentAssocPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentAssocPeer::ID, $id, $comparison); @@ -286,7 +314,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -329,7 +358,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -372,7 +402,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $query->filterByContentId(1234); // WHERE content_id = 1234 * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 + * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 * * * @see filterByContent() @@ -415,7 +446,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -541,8 +573,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentAssocQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -617,8 +649,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentAssocQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -693,8 +725,8 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentAssocQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseContentFolder.php b/core/lib/Thelia/Model/om/BaseContentFolder.php index 37997e02c..4d4050d29 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolder.php +++ b/core/lib/Thelia/Model/om/BaseContentFolder.php @@ -97,6 +97,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [content_id] column value. * @@ -136,22 +142,25 @@ abstract class BaseContentFolder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -173,22 +182,25 @@ abstract class BaseContentFolder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -199,7 +211,7 @@ abstract class BaseContentFolder extends BaseObject implements Persistent */ public function setContentId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -224,7 +236,7 @@ abstract class BaseContentFolder extends BaseObject implements Persistent */ public function setFolderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -330,7 +342,7 @@ abstract class BaseContentFolder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = ContentFolderPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -578,16 +590,16 @@ abstract class BaseContentFolder extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`CONTENT_ID`'; + $modifiedColumns[':p' . $index++] = '`content_id`'; } if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`FOLDER_ID`'; + $modifiedColumns[':p' . $index++] = '`folder_id`'; } if ($this->isColumnModified(ContentFolderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -600,16 +612,16 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`CONTENT_ID`': + case '`content_id`': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`FOLDER_ID`': + case '`folder_id`': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -673,11 +685,11 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1062,12 +1074,13 @@ abstract class BaseContentFolder extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->content_id !== null)) { + if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1113,12 +1126,13 @@ abstract class BaseContentFolder extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->folder_id !== null)) { + if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1143,6 +1157,7 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1160,7 +1175,16 @@ abstract class BaseContentFolder extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aContent = null; diff --git a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php index 30a858ff2..0af59f3e4 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php @@ -46,17 +46,17 @@ abstract class BaseContentFolderPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the CONTENT_ID field */ - const CONTENT_ID = 'content_folder.CONTENT_ID'; + /** the column name for the content_id field */ + const CONTENT_ID = 'content_folder.content_id'; - /** the column name for the FOLDER_ID field */ - const FOLDER_ID = 'content_folder.FOLDER_ID'; + /** the column name for the folder_id field */ + const FOLDER_ID = 'content_folder.folder_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'content_folder.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'content_folder.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'content_folder.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'content_folder.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -176,10 +176,10 @@ abstract class BaseContentFolderPeer $criteria->addSelectColumn(ContentFolderPeer::CREATED_AT); $criteria->addSelectColumn(ContentFolderPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.content_id'); + $criteria->addSelectColumn($alias . '.folder_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -263,7 +263,7 @@ abstract class BaseContentFolderPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -368,8 +368,15 @@ abstract class BaseContentFolderPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ContentFolderPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ContentFolderPeer::$instances = array(); } @@ -1135,7 +1142,7 @@ abstract class BaseContentFolderPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ContentFolderPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php index bea1b9b9c..0a44bc555 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php @@ -78,7 +78,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * Returns a new ContentFolderQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ContentFolderQuery|Criteria $criteria Optional Criteria to build the query from + * @param ContentFolderQuery|Criteria $criteria Optional Criteria to build the query from * * @return ContentFolderQuery */ @@ -142,12 +142,12 @@ abstract class BaseContentFolderQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ContentFolder A model object, or null if the key is not found - * @throws PropelException + * @return ContentFolder A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `CONTENT_ID`, `FOLDER_ID`, `CREATED_AT`, `UPDATED_AT` FROM `content_folder` WHERE `CONTENT_ID` = :p0 AND `FOLDER_ID` = :p1'; + $sql = 'SELECT `content_id`, `folder_id`, `created_at`, `updated_at` FROM `content_folder` WHERE `content_id` = :p0 AND `folder_id` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -255,7 +255,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * $query->filterByContentId(1234); // WHERE content_id = 1234 * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 + * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 * * * @see filterByContent() @@ -270,8 +271,22 @@ abstract class BaseContentFolderQuery extends ModelCriteria */ public function filterByContentId($contentId = null, $comparison = null) { - if (is_array($contentId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId, $comparison); @@ -284,7 +299,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * $query->filterByFolderId(1234); // WHERE folder_id = 1234 * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 + * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 * * * @see filterByFolder() @@ -299,8 +315,22 @@ abstract class BaseContentFolderQuery extends ModelCriteria */ public function filterByFolderId($folderId = null, $comparison = null) { - if (is_array($folderId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($folderId)) { + $useMinMax = false; + if (isset($folderId['min'])) { + $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($folderId['max'])) { + $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId, $comparison); @@ -398,8 +428,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentFolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentFolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { @@ -474,8 +504,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentFolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentFolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseContentI18n.php b/core/lib/Thelia/Model/om/BaseContentI18n.php index 3e7404598..b55e21f28 100644 --- a/core/lib/Thelia/Model/om/BaseContentI18n.php +++ b/core/lib/Thelia/Model/om/BaseContentI18n.php @@ -53,7 +53,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ContentI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseContentI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ContentI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ContentI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ContentI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ContentI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ContentI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ContentI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseContentI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseContentI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseContentI18n extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->id !== null)) { + if ($this->aContent === null && ($this->id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseContentI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseContentI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aContent = null; diff --git a/core/lib/Thelia/Model/om/BaseContentI18nPeer.php b/core/lib/Thelia/Model/om/BaseContentI18nPeer.php index 0e7937255..364753e50 100644 --- a/core/lib/Thelia/Model/om/BaseContentI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseContentI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'content_i18n.ID'; + /** the column name for the id field */ + const ID = 'content_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'content_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'content_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'content_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'content_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'content_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'content_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'content_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'content_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'content_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'content_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseContentI18nPeer $criteria->addSelectColumn(ContentI18nPeer::CHAPO); $criteria->addSelectColumn(ContentI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseContentI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseContentI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ContentI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ContentI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseContentI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ContentI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php b/core/lib/Thelia/Model/om/BaseContentI18nQuery.php index e55a2c086..44aa8dab2 100644 --- a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * Returns a new ContentI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ContentI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ContentI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ContentI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseContentI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ContentI18n A model object, or null if the key is not found - * @throws PropelException + * @return ContentI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `content_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `content_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseContentI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByContent() @@ -273,8 +274,22 @@ abstract class BaseContentI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseContentI18nQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php index 15a421204..070b2830c 100644 --- a/core/lib/Thelia/Model/om/BaseContentPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentPeer.php @@ -51,29 +51,29 @@ abstract class BaseContentPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'content.ID'; + /** the column name for the id field */ + const ID = 'content.id'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'content.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'content.visible'; - /** the column name for the POSITION field */ - const POSITION = 'content.POSITION'; + /** the column name for the position field */ + const POSITION = 'content.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'content.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'content.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'content.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'content.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'content.VERSION'; + /** the column name for the version field */ + const VERSION = 'content.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'content.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'content.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'content.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'content.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -93,7 +93,7 @@ abstract class BaseContentPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; // versionable behavior /** @@ -211,14 +211,14 @@ abstract class BaseContentPeer $criteria->addSelectColumn(ContentPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(ContentPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -302,7 +302,7 @@ abstract class BaseContentPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -407,8 +407,15 @@ abstract class BaseContentPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ContentPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ContentPeer::$instances = array(); } @@ -564,7 +571,7 @@ abstract class BaseContentPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ContentPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php index 1c520e69b..6c86a3bba 100644 --- a/core/lib/Thelia/Model/om/BaseContentQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentQuery.php @@ -81,7 +81,6 @@ use Thelia\Model\Rewriting; * @method Content findOne(PropelPDO $con = null) Return the first Content matching the query * @method Content findOneOrCreate(PropelPDO $con = null) Return the first Content matching the query, or a new Content object populated from the query conditions when no match is found * - * @method Content findOneById(int $id) Return the first Content filtered by the id column * @method Content findOneByVisible(int $visible) Return the first Content filtered by the visible column * @method Content findOneByPosition(int $position) Return the first Content filtered by the position column * @method Content findOneByCreatedAt(string $created_at) Return the first Content filtered by the created_at column @@ -119,7 +118,7 @@ abstract class BaseContentQuery extends ModelCriteria * Returns a new ContentQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ContentQuery|Criteria $criteria Optional Criteria to build the query from + * @param ContentQuery|Criteria $criteria Optional Criteria to build the query from * * @return ContentQuery */ @@ -175,6 +174,20 @@ abstract class BaseContentQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Content A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -182,12 +195,12 @@ abstract class BaseContentQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Content A model object, or null if the key is not found - * @throws PropelException + * @return Content A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `content` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `content` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -283,7 +296,8 @@ abstract class BaseContentQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -296,8 +310,22 @@ abstract class BaseContentQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentPeer::ID, $id, $comparison); @@ -310,7 +338,8 @@ abstract class BaseContentQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -351,7 +380,8 @@ abstract class BaseContentQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -478,7 +508,8 @@ abstract class BaseContentQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -590,8 +621,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentAssoc($contentAssoc, $comparison = null) { @@ -664,8 +695,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param Image|PropelObjectCollection $image the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImage($image, $comparison = null) { @@ -738,8 +769,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param Document|PropelObjectCollection $document the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocument($document, $comparison = null) { @@ -812,8 +843,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByRewriting($rewriting, $comparison = null) { @@ -886,8 +917,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentFolder($contentFolder, $comparison = null) { @@ -960,8 +991,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param ContentI18n|PropelObjectCollection $contentI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentI18n($contentI18n, $comparison = null) { @@ -1034,8 +1065,8 @@ abstract class BaseContentQuery extends ModelCriteria * @param ContentVersion|PropelObjectCollection $contentVersion the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentVersion($contentVersion, $comparison = null) { @@ -1194,7 +1225,7 @@ abstract class BaseContentQuery extends ModelCriteria * * @return ContentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; @@ -1212,7 +1243,7 @@ abstract class BaseContentQuery extends ModelCriteria * * @return ContentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1233,7 +1264,7 @@ abstract class BaseContentQuery extends ModelCriteria * * @return ContentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseContentVersion.php b/core/lib/Thelia/Model/om/BaseContentVersion.php index b6bc1d06c..423d1a2ac 100644 --- a/core/lib/Thelia/Model/om/BaseContentVersion.php +++ b/core/lib/Thelia/Model/om/BaseContentVersion.php @@ -115,6 +115,12 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -185,22 +191,25 @@ abstract class BaseContentVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -222,22 +231,25 @@ abstract class BaseContentVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -269,22 +281,25 @@ abstract class BaseContentVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -305,7 +320,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -330,7 +345,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -351,7 +366,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -418,7 +433,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -462,7 +477,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -526,7 +541,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = ContentVersionPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -752,28 +767,28 @@ abstract class BaseContentVersion extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ContentVersionPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ContentVersionPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(ContentVersionPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ContentVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ContentVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(ContentVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(ContentVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -786,28 +801,28 @@ abstract class BaseContentVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -871,11 +886,11 @@ abstract class BaseContentVersion extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1291,12 +1306,13 @@ abstract class BaseContentVersion extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->id !== null)) { + if ($this->aContent === null && ($this->id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1325,6 +1341,7 @@ abstract class BaseContentVersion extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1343,7 +1360,13 @@ abstract class BaseContentVersion extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aContent = null; diff --git a/core/lib/Thelia/Model/om/BaseContentVersionPeer.php b/core/lib/Thelia/Model/om/BaseContentVersionPeer.php index c734a84bd..1e2888f75 100644 --- a/core/lib/Thelia/Model/om/BaseContentVersionPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentVersionPeer.php @@ -45,29 +45,29 @@ abstract class BaseContentVersionPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'content_version.ID'; + /** the column name for the id field */ + const ID = 'content_version.id'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'content_version.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'content_version.visible'; - /** the column name for the POSITION field */ - const POSITION = 'content_version.POSITION'; + /** the column name for the position field */ + const POSITION = 'content_version.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'content_version.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'content_version.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'content_version.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'content_version.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'content_version.VERSION'; + /** the column name for the version field */ + const VERSION = 'content_version.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'content_version.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'content_version.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'content_version.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'content_version.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -191,14 +191,14 @@ abstract class BaseContentVersionPeer $criteria->addSelectColumn(ContentVersionPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(ContentVersionPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -282,7 +282,7 @@ abstract class BaseContentVersionPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -387,8 +387,15 @@ abstract class BaseContentVersionPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ContentVersionPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ContentVersionPeer::$instances = array(); } @@ -761,7 +768,7 @@ abstract class BaseContentVersionPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ContentVersionPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php b/core/lib/Thelia/Model/om/BaseContentVersionQuery.php index fa736c86b..576a3ac02 100644 --- a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentVersionQuery.php @@ -89,7 +89,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * Returns a new ContentVersionQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ContentVersionQuery|Criteria $criteria Optional Criteria to build the query from + * @param ContentVersionQuery|Criteria $criteria Optional Criteria to build the query from * * @return ContentVersionQuery */ @@ -153,12 +153,12 @@ abstract class BaseContentVersionQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ContentVersion A model object, or null if the key is not found - * @throws PropelException + * @return ContentVersion A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `content_version` WHERE `ID` = :p0 AND `VERSION` = :p1'; + $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `content_version` WHERE `id` = :p0 AND `version` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -266,7 +266,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByContent() @@ -281,8 +282,22 @@ abstract class BaseContentVersionQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentVersionPeer::ID, $id, $comparison); @@ -295,7 +310,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -336,7 +352,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -463,7 +480,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -476,8 +494,22 @@ abstract class BaseContentVersionQuery extends ModelCriteria */ public function filterByVersion($version = null, $comparison = null) { - if (is_array($version) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(ContentVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(ContentVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ContentVersionPeer::VERSION, $version, $comparison); @@ -561,8 +593,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ContentVersionQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ContentVersionQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCountry.php b/core/lib/Thelia/Model/om/BaseCountry.php index 018d56813..964ccac65 100644 --- a/core/lib/Thelia/Model/om/BaseCountry.php +++ b/core/lib/Thelia/Model/om/BaseCountry.php @@ -126,13 +126,19 @@ abstract class BaseCountry extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -221,22 +227,25 @@ abstract class BaseCountry extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -258,22 +267,25 @@ abstract class BaseCountry extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -284,7 +296,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -305,7 +317,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function setAreaId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -330,7 +342,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function setIsocode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -351,7 +363,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function setIsoalpha2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -372,7 +384,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function setIsoalpha3($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -477,7 +489,7 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = CountryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -707,7 +719,7 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($this->collTaxRuleCountrys !== null) { foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -724,7 +736,7 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($this->collCountryI18ns !== null) { foreach ($this->collCountryI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -753,25 +765,25 @@ abstract class BaseCountry extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CountryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CountryPeer::AREA_ID)) { - $modifiedColumns[':p' . $index++] = '`AREA_ID`'; + $modifiedColumns[':p' . $index++] = '`area_id`'; } if ($this->isColumnModified(CountryPeer::ISOCODE)) { - $modifiedColumns[':p' . $index++] = '`ISOCODE`'; + $modifiedColumns[':p' . $index++] = '`isocode`'; } if ($this->isColumnModified(CountryPeer::ISOALPHA2)) { - $modifiedColumns[':p' . $index++] = '`ISOALPHA2`'; + $modifiedColumns[':p' . $index++] = '`isoalpha2`'; } if ($this->isColumnModified(CountryPeer::ISOALPHA3)) { - $modifiedColumns[':p' . $index++] = '`ISOALPHA3`'; + $modifiedColumns[':p' . $index++] = '`isoalpha3`'; } if ($this->isColumnModified(CountryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CountryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -784,25 +796,25 @@ abstract class BaseCountry extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`AREA_ID`': + case '`area_id`': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case '`ISOCODE`': + case '`isocode`': $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR); break; - case '`ISOALPHA2`': + case '`isoalpha2`': $stmt->bindValue($identifier, $this->isoalpha2, PDO::PARAM_STR); break; - case '`ISOALPHA3`': + case '`isoalpha3`': $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -866,11 +878,11 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1303,12 +1315,13 @@ abstract class BaseCountry extends BaseObject implements Persistent * Get the associated Area object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Area The associated Area object. * @throws PropelException */ - public function getArea(PropelPDO $con = null) + public function getArea(PropelPDO $con = null, $doQuery = true) { - if ($this->aArea === null && ($this->area_id !== null)) { + if ($this->aArea === null && ($this->area_id !== null) && $doQuery) { $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1347,13 +1360,15 @@ abstract class BaseCountry extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Country The current object (for fluent API support) * @see addTaxRuleCountrys() */ public function clearTaxRuleCountrys() { $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized $this->collTaxRuleCountrysPartial = null; + + return $this; } /** @@ -1425,6 +1440,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->collTaxRuleCountrysPartial = true; } + $collTaxRuleCountrys->getInternalIterator()->rewind(); return $collTaxRuleCountrys; } @@ -1452,12 +1468,15 @@ abstract class BaseCountry extends BaseObject implements Persistent * * @param PropelCollection $taxRuleCountrys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Country The current object (for fluent API support) */ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) { - $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); + $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) { + $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); + + foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { $taxRuleCountryRemoved->setCountry(null); } @@ -1468,6 +1487,8 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->collTaxRuleCountrys = $taxRuleCountrys; $this->collTaxRuleCountrysPartial = false; + + return $this; } /** @@ -1485,22 +1506,22 @@ abstract class BaseCountry extends BaseObject implements Persistent if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTaxRuleCountrys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCountry($this) - ->count($con); } - } else { - return count($this->collTaxRuleCountrys); + + if($partial && !$criteria) { + return count($this->getTaxRuleCountrys()); + } + $query = TaxRuleCountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCountry($this) + ->count($con); } + + return count($this->collTaxRuleCountrys); } /** @@ -1516,7 +1537,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->initTaxRuleCountrys(); $this->collTaxRuleCountrysPartial = true; } - if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleCountry($l); } @@ -1534,6 +1555,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return Country The current object (for fluent API support) */ public function removeTaxRuleCountry($taxRuleCountry) { @@ -1546,6 +1568,8 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; $taxRuleCountry->setCountry(null); } + + return $this; } @@ -1604,13 +1628,15 @@ abstract class BaseCountry extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Country The current object (for fluent API support) * @see addCountryI18ns() */ public function clearCountryI18ns() { $this->collCountryI18ns = null; // important to set this to null since that means it is uninitialized $this->collCountryI18nsPartial = null; + + return $this; } /** @@ -1682,6 +1708,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->collCountryI18nsPartial = true; } + $collCountryI18ns->getInternalIterator()->rewind(); return $collCountryI18ns; } @@ -1709,12 +1736,15 @@ abstract class BaseCountry extends BaseObject implements Persistent * * @param PropelCollection $countryI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Country The current object (for fluent API support) */ public function setCountryI18ns(PropelCollection $countryI18ns, PropelPDO $con = null) { - $this->countryI18nsScheduledForDeletion = $this->getCountryI18ns(new Criteria(), $con)->diff($countryI18ns); + $countryI18nsToDelete = $this->getCountryI18ns(new Criteria(), $con)->diff($countryI18ns); - foreach ($this->countryI18nsScheduledForDeletion as $countryI18nRemoved) { + $this->countryI18nsScheduledForDeletion = unserialize(serialize($countryI18nsToDelete)); + + foreach ($countryI18nsToDelete as $countryI18nRemoved) { $countryI18nRemoved->setCountry(null); } @@ -1725,6 +1755,8 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->collCountryI18ns = $countryI18ns; $this->collCountryI18nsPartial = false; + + return $this; } /** @@ -1742,22 +1774,22 @@ abstract class BaseCountry extends BaseObject implements Persistent if (null === $this->collCountryI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCountryI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCountryI18ns()); - } - $query = CountryI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCountry($this) - ->count($con); } - } else { - return count($this->collCountryI18ns); + + if($partial && !$criteria) { + return count($this->getCountryI18ns()); + } + $query = CountryI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCountry($this) + ->count($con); } + + return count($this->collCountryI18ns); } /** @@ -1777,7 +1809,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->initCountryI18ns(); $this->collCountryI18nsPartial = true; } - if (!$this->collCountryI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCountryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCountryI18n($l); } @@ -1795,6 +1827,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * @param CountryI18n $countryI18n The countryI18n object to remove. + * @return Country The current object (for fluent API support) */ public function removeCountryI18n($countryI18n) { @@ -1804,9 +1837,11 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->countryI18nsScheduledForDeletion = clone $this->collCountryI18ns; $this->countryI18nsScheduledForDeletion->clear(); } - $this->countryI18nsScheduledForDeletion[]= $countryI18n; + $this->countryI18nsScheduledForDeletion[]= clone $countryI18n; $countryI18n->setCountry(null); } + + return $this; } /** @@ -1823,6 +1858,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1840,7 +1876,8 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collTaxRuleCountrys) { foreach ($this->collTaxRuleCountrys as $o) { $o->clearAllReferences($deep); @@ -1851,10 +1888,15 @@ abstract class BaseCountry extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aArea instanceof Persistent) { + $this->aArea->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collTaxRuleCountrys instanceof PropelCollection) { @@ -1911,7 +1953,7 @@ abstract class BaseCountry extends BaseObject implements Persistent * * @return Country The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1935,7 +1977,7 @@ abstract class BaseCountry extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return CountryI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCountryI18ns) { @@ -1970,7 +2012,7 @@ abstract class BaseCountry extends BaseObject implements Persistent * * @return Country The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { CountryI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseCountryI18n.php b/core/lib/Thelia/Model/om/BaseCountryI18n.php index 5e5395710..eb0d82b80 100644 --- a/core/lib/Thelia/Model/om/BaseCountryI18n.php +++ b/core/lib/Thelia/Model/om/BaseCountryI18n.php @@ -53,7 +53,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = CountryI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CountryI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CountryI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(CountryI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(CountryI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(CountryI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(CountryI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent * Get the associated Country object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Country The associated Country object. * @throws PropelException */ - public function getCountry(PropelPDO $con = null) + public function getCountry(PropelPDO $con = null, $doQuery = true) { - if ($this->aCountry === null && ($this->id !== null)) { + if ($this->aCountry === null && ($this->id !== null) && $doQuery) { $this->aCountry = CountryQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseCountryI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCountry instanceof Persistent) { + $this->aCountry->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCountry = null; diff --git a/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php b/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php index 15604ceba..bb9cc78ce 100644 --- a/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseCountryI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'country_i18n.ID'; + /** the column name for the id field */ + const ID = 'country_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'country_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'country_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'country_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'country_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'country_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'country_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'country_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'country_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'country_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'country_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseCountryI18nPeer $criteria->addSelectColumn(CountryI18nPeer::CHAPO); $criteria->addSelectColumn(CountryI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseCountryI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseCountryI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CountryI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CountryI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseCountryI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CountryI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php b/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php index d9d421852..ed1ff2f7a 100644 --- a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * Returns a new CountryI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CountryI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param CountryI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return CountryI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CountryI18n A model object, or null if the key is not found - * @throws PropelException + * @return CountryI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `country_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `country_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByCountry() @@ -273,8 +274,22 @@ abstract class BaseCountryI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CountryI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CountryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CountryI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * @param Country|PropelObjectCollection $country The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CountryI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CountryI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCountry($country, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCountryPeer.php b/core/lib/Thelia/Model/om/BaseCountryPeer.php index c4f3d1ccf..8101527b5 100644 --- a/core/lib/Thelia/Model/om/BaseCountryPeer.php +++ b/core/lib/Thelia/Model/om/BaseCountryPeer.php @@ -47,26 +47,26 @@ abstract class BaseCountryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'country.ID'; + /** the column name for the id field */ + const ID = 'country.id'; - /** the column name for the AREA_ID field */ - const AREA_ID = 'country.AREA_ID'; + /** the column name for the area_id field */ + const AREA_ID = 'country.area_id'; - /** the column name for the ISOCODE field */ - const ISOCODE = 'country.ISOCODE'; + /** the column name for the isocode field */ + const ISOCODE = 'country.isocode'; - /** the column name for the ISOALPHA2 field */ - const ISOALPHA2 = 'country.ISOALPHA2'; + /** the column name for the isoalpha2 field */ + const ISOALPHA2 = 'country.isoalpha2'; - /** the column name for the ISOALPHA3 field */ - const ISOALPHA3 = 'country.ISOALPHA3'; + /** the column name for the isoalpha3 field */ + const ISOALPHA3 = 'country.isoalpha3'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'country.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'country.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'country.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'country.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -86,7 +86,7 @@ abstract class BaseCountryPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -196,13 +196,13 @@ abstract class BaseCountryPeer $criteria->addSelectColumn(CountryPeer::CREATED_AT); $criteria->addSelectColumn(CountryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.AREA_ID'); - $criteria->addSelectColumn($alias . '.ISOCODE'); - $criteria->addSelectColumn($alias . '.ISOALPHA2'); - $criteria->addSelectColumn($alias . '.ISOALPHA3'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.area_id'); + $criteria->addSelectColumn($alias . '.isocode'); + $criteria->addSelectColumn($alias . '.isoalpha2'); + $criteria->addSelectColumn($alias . '.isoalpha3'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -286,7 +286,7 @@ abstract class BaseCountryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -391,8 +391,15 @@ abstract class BaseCountryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CountryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CountryPeer::$instances = array(); } @@ -771,7 +778,7 @@ abstract class BaseCountryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CountryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/om/BaseCountryQuery.php index 67523456f..24c22c0b7 100644 --- a/core/lib/Thelia/Model/om/BaseCountryQuery.php +++ b/core/lib/Thelia/Model/om/BaseCountryQuery.php @@ -59,7 +59,6 @@ use Thelia\Model\TaxRuleCountry; * @method Country findOne(PropelPDO $con = null) Return the first Country matching the query * @method Country findOneOrCreate(PropelPDO $con = null) Return the first Country matching the query, or a new Country object populated from the query conditions when no match is found * - * @method Country findOneById(int $id) Return the first Country filtered by the id column * @method Country findOneByAreaId(int $area_id) Return the first Country filtered by the area_id column * @method Country findOneByIsocode(string $isocode) Return the first Country filtered by the isocode column * @method Country findOneByIsoalpha2(string $isoalpha2) Return the first Country filtered by the isoalpha2 column @@ -95,7 +94,7 @@ abstract class BaseCountryQuery extends ModelCriteria * Returns a new CountryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CountryQuery|Criteria $criteria Optional Criteria to build the query from + * @param CountryQuery|Criteria $criteria Optional Criteria to build the query from * * @return CountryQuery */ @@ -151,6 +150,20 @@ abstract class BaseCountryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Country A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -158,12 +171,12 @@ abstract class BaseCountryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Country A model object, or null if the key is not found - * @throws PropelException + * @return Country A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `AREA_ID`, `ISOCODE`, `ISOALPHA2`, `ISOALPHA3`, `CREATED_AT`, `UPDATED_AT` FROM `country` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at` FROM `country` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -259,7 +272,8 @@ abstract class BaseCountryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -272,8 +286,22 @@ abstract class BaseCountryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CountryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CountryPeer::ID, $id, $comparison); @@ -286,7 +314,8 @@ abstract class BaseCountryQuery extends ModelCriteria * * $query->filterByAreaId(1234); // WHERE area_id = 1234 * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) - * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id >= 12 + * $query->filterByAreaId(array('max' => 12)); // WHERE area_id <= 12 * * * @see filterByArea() @@ -501,8 +530,8 @@ abstract class BaseCountryQuery extends ModelCriteria * @param Area|PropelObjectCollection $area The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByArea($area, $comparison = null) { @@ -577,8 +606,8 @@ abstract class BaseCountryQuery extends ModelCriteria * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { @@ -651,8 +680,8 @@ abstract class BaseCountryQuery extends ModelCriteria * @param CountryI18n|PropelObjectCollection $countryI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCountryI18n($countryI18n, $comparison = null) { @@ -811,7 +840,7 @@ abstract class BaseCountryQuery extends ModelCriteria * * @return CountryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; @@ -829,7 +858,7 @@ abstract class BaseCountryQuery extends ModelCriteria * * @return CountryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -850,7 +879,7 @@ abstract class BaseCountryQuery extends ModelCriteria * * @return CountryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/om/BaseCoupon.php index 639cfc5e0..345437ab2 100644 --- a/core/lib/Thelia/Model/om/BaseCoupon.php +++ b/core/lib/Thelia/Model/om/BaseCoupon.php @@ -129,6 +129,12 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -204,22 +210,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->available_since); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->available_since, true), $x); - } + } + + try { + $dt = new DateTime($this->available_since); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->available_since, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -241,22 +250,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->date_limit); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->date_limit, true), $x); - } + } + + try { + $dt = new DateTime($this->date_limit); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->date_limit, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -288,22 +300,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -325,22 +340,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -351,7 +369,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -372,7 +390,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -393,7 +411,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setAction($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -414,7 +432,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setValue($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -435,7 +453,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setUsed($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -502,7 +520,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function setActivate($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -610,7 +628,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 10; // 10 = CouponPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -821,7 +839,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent if ($this->collCouponRules !== null) { foreach ($this->collCouponRules as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -854,34 +872,34 @@ abstract class BaseCoupon extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CouponPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CouponPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(CouponPeer::ACTION)) { - $modifiedColumns[':p' . $index++] = '`ACTION`'; + $modifiedColumns[':p' . $index++] = '`action`'; } if ($this->isColumnModified(CouponPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`VALUE`'; + $modifiedColumns[':p' . $index++] = '`value`'; } if ($this->isColumnModified(CouponPeer::USED)) { - $modifiedColumns[':p' . $index++] = '`USED`'; + $modifiedColumns[':p' . $index++] = '`used`'; } if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) { - $modifiedColumns[':p' . $index++] = '`AVAILABLE_SINCE`'; + $modifiedColumns[':p' . $index++] = '`available_since`'; } if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) { - $modifiedColumns[':p' . $index++] = '`DATE_LIMIT`'; + $modifiedColumns[':p' . $index++] = '`date_limit`'; } if ($this->isColumnModified(CouponPeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`ACTIVATE`'; + $modifiedColumns[':p' . $index++] = '`activate`'; } if ($this->isColumnModified(CouponPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CouponPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -894,34 +912,34 @@ abstract class BaseCoupon extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`ACTION`': + case '`action`': $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); break; - case '`VALUE`': + case '`value`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`USED`': + case '`used`': $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT); break; - case '`AVAILABLE_SINCE`': + case '`available_since`': $stmt->bindValue($identifier, $this->available_since, PDO::PARAM_STR); break; - case '`DATE_LIMIT`': + case '`date_limit`': $stmt->bindValue($identifier, $this->date_limit, PDO::PARAM_STR); break; - case '`ACTIVATE`': + case '`activate`': $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -992,11 +1010,11 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1417,13 +1435,15 @@ abstract class BaseCoupon extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Coupon The current object (for fluent API support) * @see addCouponRules() */ public function clearCouponRules() { $this->collCouponRules = null; // important to set this to null since that means it is uninitialized $this->collCouponRulesPartial = null; + + return $this; } /** @@ -1495,6 +1515,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->collCouponRulesPartial = true; } + $collCouponRules->getInternalIterator()->rewind(); return $collCouponRules; } @@ -1522,12 +1543,15 @@ abstract class BaseCoupon extends BaseObject implements Persistent * * @param PropelCollection $couponRules A Propel collection. * @param PropelPDO $con Optional connection object + * @return Coupon The current object (for fluent API support) */ public function setCouponRules(PropelCollection $couponRules, PropelPDO $con = null) { - $this->couponRulesScheduledForDeletion = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); + $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); - foreach ($this->couponRulesScheduledForDeletion as $couponRuleRemoved) { + $this->couponRulesScheduledForDeletion = unserialize(serialize($couponRulesToDelete)); + + foreach ($couponRulesToDelete as $couponRuleRemoved) { $couponRuleRemoved->setCoupon(null); } @@ -1538,6 +1562,8 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->collCouponRules = $couponRules; $this->collCouponRulesPartial = false; + + return $this; } /** @@ -1555,22 +1581,22 @@ abstract class BaseCoupon extends BaseObject implements Persistent if (null === $this->collCouponRules || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCouponRules) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCouponRules()); - } - $query = CouponRuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCoupon($this) - ->count($con); } - } else { - return count($this->collCouponRules); + + if($partial && !$criteria) { + return count($this->getCouponRules()); + } + $query = CouponRuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCoupon($this) + ->count($con); } + + return count($this->collCouponRules); } /** @@ -1586,7 +1612,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->initCouponRules(); $this->collCouponRulesPartial = true; } - if (!$this->collCouponRules->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCouponRules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCouponRule($l); } @@ -1604,6 +1630,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * @param CouponRule $couponRule The couponRule object to remove. + * @return Coupon The current object (for fluent API support) */ public function removeCouponRule($couponRule) { @@ -1613,9 +1640,11 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->couponRulesScheduledForDeletion = clone $this->collCouponRules; $this->couponRulesScheduledForDeletion->clear(); } - $this->couponRulesScheduledForDeletion[]= $couponRule; + $this->couponRulesScheduledForDeletion[]= clone $couponRule; $couponRule->setCoupon(null); } + + return $this; } /** @@ -1635,6 +1664,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1652,12 +1682,15 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collCouponRules) { foreach ($this->collCouponRules as $o) { $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collCouponRules instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseCouponOrder.php b/core/lib/Thelia/Model/om/BaseCouponOrder.php index 60a6e581d..5bdef9ed4 100644 --- a/core/lib/Thelia/Model/om/BaseCouponOrder.php +++ b/core/lib/Thelia/Model/om/BaseCouponOrder.php @@ -102,6 +102,12 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -161,22 +167,25 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -198,22 +207,25 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -224,7 +236,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -245,7 +257,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ public function setOrderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -270,7 +282,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -291,7 +303,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ public function setValue($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -395,7 +407,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = CouponOrderPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -636,22 +648,22 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CouponOrderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CouponOrderPeer::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = '`ORDER_ID`'; + $modifiedColumns[':p' . $index++] = '`order_id`'; } if ($this->isColumnModified(CouponOrderPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(CouponOrderPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`VALUE`'; + $modifiedColumns[':p' . $index++] = '`value`'; } if ($this->isColumnModified(CouponOrderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -664,22 +676,22 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ORDER_ID`': + case '`order_id`': $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`VALUE`': + case '`value`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -750,11 +762,11 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1143,12 +1155,13 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent * Get the associated Order object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Order The associated Order object. * @throws PropelException */ - public function getOrder(PropelPDO $con = null) + public function getOrder(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrder === null && ($this->order_id !== null)) { + if ($this->aOrder === null && ($this->order_id !== null) && $doQuery) { $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1175,6 +1188,7 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1192,7 +1206,13 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aOrder instanceof Persistent) { + $this->aOrder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aOrder = null; diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php index 30b8f5429..7935f735e 100644 --- a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php +++ b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php @@ -45,23 +45,23 @@ abstract class BaseCouponOrderPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'coupon_order.ID'; + /** the column name for the id field */ + const ID = 'coupon_order.id'; - /** the column name for the ORDER_ID field */ - const ORDER_ID = 'coupon_order.ORDER_ID'; + /** the column name for the order_id field */ + const ORDER_ID = 'coupon_order.order_id'; - /** the column name for the CODE field */ - const CODE = 'coupon_order.CODE'; + /** the column name for the code field */ + const CODE = 'coupon_order.code'; - /** the column name for the VALUE field */ - const VALUE = 'coupon_order.VALUE'; + /** the column name for the value field */ + const VALUE = 'coupon_order.value'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'coupon_order.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'coupon_order.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'coupon_order.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'coupon_order.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseCouponOrderPeer $criteria->addSelectColumn(CouponOrderPeer::CREATED_AT); $criteria->addSelectColumn(CouponOrderPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ORDER_ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.order_id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -272,7 +272,7 @@ abstract class BaseCouponOrderPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseCouponOrderPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CouponOrderPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CouponOrderPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseCouponOrderPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CouponOrderPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php index 8f29b1a0e..5a6f86656 100644 --- a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php @@ -47,7 +47,6 @@ use Thelia\Model\Order; * @method CouponOrder findOne(PropelPDO $con = null) Return the first CouponOrder matching the query * @method CouponOrder findOneOrCreate(PropelPDO $con = null) Return the first CouponOrder matching the query, or a new CouponOrder object populated from the query conditions when no match is found * - * @method CouponOrder findOneById(int $id) Return the first CouponOrder filtered by the id column * @method CouponOrder findOneByOrderId(int $order_id) Return the first CouponOrder filtered by the order_id column * @method CouponOrder findOneByCode(string $code) Return the first CouponOrder filtered by the code column * @method CouponOrder findOneByValue(double $value) Return the first CouponOrder filtered by the value column @@ -81,7 +80,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * Returns a new CouponOrderQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CouponOrderQuery|Criteria $criteria Optional Criteria to build the query from + * @param CouponOrderQuery|Criteria $criteria Optional Criteria to build the query from * * @return CouponOrderQuery */ @@ -137,6 +136,20 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CouponOrder A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -144,12 +157,12 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CouponOrder A model object, or null if the key is not found - * @throws PropelException + * @return CouponOrder A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon_order` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `order_id`, `code`, `value`, `created_at`, `updated_at` FROM `coupon_order` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -245,7 +258,8 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -258,8 +272,22 @@ abstract class BaseCouponOrderQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponOrderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponOrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CouponOrderPeer::ID, $id, $comparison); @@ -272,7 +300,8 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $query->filterByOrderId(1234); // WHERE order_id = 1234 * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) - * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id >= 12 + * $query->filterByOrderId(array('max' => 12)); // WHERE order_id <= 12 * * * @see filterByOrder() @@ -344,7 +373,8 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $query->filterByValue(1234); // WHERE value = 1234 * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 + * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 * * * @param mixed $value The value to use as filter. @@ -470,8 +500,8 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * @param Order|PropelObjectCollection $order The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CouponOrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CouponOrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrder($order, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCouponPeer.php b/core/lib/Thelia/Model/om/BaseCouponPeer.php index dcc446f3c..4af0f4e3d 100644 --- a/core/lib/Thelia/Model/om/BaseCouponPeer.php +++ b/core/lib/Thelia/Model/om/BaseCouponPeer.php @@ -45,35 +45,35 @@ abstract class BaseCouponPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 10; - /** the column name for the ID field */ - const ID = 'coupon.ID'; + /** the column name for the id field */ + const ID = 'coupon.id'; - /** the column name for the CODE field */ - const CODE = 'coupon.CODE'; + /** the column name for the code field */ + const CODE = 'coupon.code'; - /** the column name for the ACTION field */ - const ACTION = 'coupon.ACTION'; + /** the column name for the action field */ + const ACTION = 'coupon.action'; - /** the column name for the VALUE field */ - const VALUE = 'coupon.VALUE'; + /** the column name for the value field */ + const VALUE = 'coupon.value'; - /** the column name for the USED field */ - const USED = 'coupon.USED'; + /** the column name for the used field */ + const USED = 'coupon.used'; - /** the column name for the AVAILABLE_SINCE field */ - const AVAILABLE_SINCE = 'coupon.AVAILABLE_SINCE'; + /** the column name for the available_since field */ + const AVAILABLE_SINCE = 'coupon.available_since'; - /** the column name for the DATE_LIMIT field */ - const DATE_LIMIT = 'coupon.DATE_LIMIT'; + /** the column name for the date_limit field */ + const DATE_LIMIT = 'coupon.date_limit'; - /** the column name for the ACTIVATE field */ - const ACTIVATE = 'coupon.ACTIVATE'; + /** the column name for the activate field */ + const ACTIVATE = 'coupon.activate'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'coupon.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'coupon.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'coupon.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'coupon.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -199,16 +199,16 @@ abstract class BaseCouponPeer $criteria->addSelectColumn(CouponPeer::CREATED_AT); $criteria->addSelectColumn(CouponPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.ACTION'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.USED'); - $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE'); - $criteria->addSelectColumn($alias . '.DATE_LIMIT'); - $criteria->addSelectColumn($alias . '.ACTIVATE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.action'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.used'); + $criteria->addSelectColumn($alias . '.available_since'); + $criteria->addSelectColumn($alias . '.date_limit'); + $criteria->addSelectColumn($alias . '.activate'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -292,7 +292,7 @@ abstract class BaseCouponPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -397,8 +397,15 @@ abstract class BaseCouponPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CouponPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CouponPeer::$instances = array(); } @@ -536,7 +543,7 @@ abstract class BaseCouponPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CouponPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/om/BaseCouponQuery.php index d47b8a071..4780154be 100644 --- a/core/lib/Thelia/Model/om/BaseCouponQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponQuery.php @@ -55,7 +55,6 @@ use Thelia\Model\CouponRule; * @method Coupon findOne(PropelPDO $con = null) Return the first Coupon matching the query * @method Coupon findOneOrCreate(PropelPDO $con = null) Return the first Coupon matching the query, or a new Coupon object populated from the query conditions when no match is found * - * @method Coupon findOneById(int $id) Return the first Coupon filtered by the id column * @method Coupon findOneByCode(string $code) Return the first Coupon filtered by the code column * @method Coupon findOneByAction(string $action) Return the first Coupon filtered by the action column * @method Coupon findOneByValue(double $value) Return the first Coupon filtered by the value column @@ -97,7 +96,7 @@ abstract class BaseCouponQuery extends ModelCriteria * Returns a new CouponQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CouponQuery|Criteria $criteria Optional Criteria to build the query from + * @param CouponQuery|Criteria $criteria Optional Criteria to build the query from * * @return CouponQuery */ @@ -153,6 +152,20 @@ abstract class BaseCouponQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Coupon A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -160,12 +173,12 @@ abstract class BaseCouponQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Coupon A model object, or null if the key is not found - * @throws PropelException + * @return Coupon A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `ACTION`, `VALUE`, `USED`, `AVAILABLE_SINCE`, `DATE_LIMIT`, `ACTIVATE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `action`, `value`, `used`, `available_since`, `date_limit`, `activate`, `created_at`, `updated_at` FROM `coupon` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -261,7 +274,8 @@ abstract class BaseCouponQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -274,8 +288,22 @@ abstract class BaseCouponQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CouponPeer::ID, $id, $comparison); @@ -346,7 +374,8 @@ abstract class BaseCouponQuery extends ModelCriteria * * $query->filterByValue(1234); // WHERE value = 1234 * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 + * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 * * * @param mixed $value The value to use as filter. @@ -387,7 +416,8 @@ abstract class BaseCouponQuery extends ModelCriteria * * $query->filterByUsed(1234); // WHERE used = 1234 * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34) - * $query->filterByUsed(array('min' => 12)); // WHERE used > 12 + * $query->filterByUsed(array('min' => 12)); // WHERE used >= 12 + * $query->filterByUsed(array('max' => 12)); // WHERE used <= 12 * * * @param mixed $used The value to use as filter. @@ -514,7 +544,8 @@ abstract class BaseCouponQuery extends ModelCriteria * * $query->filterByActivate(1234); // WHERE activate = 1234 * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 + * $query->filterByActivate(array('min' => 12)); // WHERE activate >= 12 + * $query->filterByActivate(array('max' => 12)); // WHERE activate <= 12 * * * @param mixed $activate The value to use as filter. @@ -640,8 +671,8 @@ abstract class BaseCouponQuery extends ModelCriteria * @param CouponRule|PropelObjectCollection $couponRule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CouponQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CouponQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCouponRule($couponRule, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCouponRule.php b/core/lib/Thelia/Model/om/BaseCouponRule.php index 95d552a58..134a0f869 100644 --- a/core/lib/Thelia/Model/om/BaseCouponRule.php +++ b/core/lib/Thelia/Model/om/BaseCouponRule.php @@ -108,6 +108,12 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -177,22 +183,25 @@ abstract class BaseCouponRule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -214,22 +223,25 @@ abstract class BaseCouponRule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -240,7 +252,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -261,7 +273,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function setCouponId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -286,7 +298,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function setController($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -307,7 +319,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function setOperation($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -328,7 +340,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function setValue($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -433,7 +445,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = CouponRulePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -674,25 +686,25 @@ abstract class BaseCouponRule extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CouponRulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CouponRulePeer::COUPON_ID)) { - $modifiedColumns[':p' . $index++] = '`COUPON_ID`'; + $modifiedColumns[':p' . $index++] = '`coupon_id`'; } if ($this->isColumnModified(CouponRulePeer::CONTROLLER)) { - $modifiedColumns[':p' . $index++] = '`CONTROLLER`'; + $modifiedColumns[':p' . $index++] = '`controller`'; } if ($this->isColumnModified(CouponRulePeer::OPERATION)) { - $modifiedColumns[':p' . $index++] = '`OPERATION`'; + $modifiedColumns[':p' . $index++] = '`operation`'; } if ($this->isColumnModified(CouponRulePeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`VALUE`'; + $modifiedColumns[':p' . $index++] = '`value`'; } if ($this->isColumnModified(CouponRulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CouponRulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -705,25 +717,25 @@ abstract class BaseCouponRule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`COUPON_ID`': + case '`coupon_id`': $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT); break; - case '`CONTROLLER`': + case '`controller`': $stmt->bindValue($identifier, $this->controller, PDO::PARAM_STR); break; - case '`OPERATION`': + case '`operation`': $stmt->bindValue($identifier, $this->operation, PDO::PARAM_STR); break; - case '`VALUE`': + case '`value`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -794,11 +806,11 @@ abstract class BaseCouponRule extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1197,12 +1209,13 @@ abstract class BaseCouponRule extends BaseObject implements Persistent * Get the associated Coupon object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Coupon The associated Coupon object. * @throws PropelException */ - public function getCoupon(PropelPDO $con = null) + public function getCoupon(PropelPDO $con = null, $doQuery = true) { - if ($this->aCoupon === null && ($this->coupon_id !== null)) { + if ($this->aCoupon === null && ($this->coupon_id !== null) && $doQuery) { $this->aCoupon = CouponQuery::create()->findPk($this->coupon_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1230,6 +1243,7 @@ abstract class BaseCouponRule extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1247,7 +1261,13 @@ abstract class BaseCouponRule extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCoupon instanceof Persistent) { + $this->aCoupon->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCoupon = null; diff --git a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php index 85d9c6c0b..061390aa0 100644 --- a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php +++ b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php @@ -45,26 +45,26 @@ abstract class BaseCouponRulePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'coupon_rule.ID'; + /** the column name for the id field */ + const ID = 'coupon_rule.id'; - /** the column name for the COUPON_ID field */ - const COUPON_ID = 'coupon_rule.COUPON_ID'; + /** the column name for the coupon_id field */ + const COUPON_ID = 'coupon_rule.coupon_id'; - /** the column name for the CONTROLLER field */ - const CONTROLLER = 'coupon_rule.CONTROLLER'; + /** the column name for the controller field */ + const CONTROLLER = 'coupon_rule.controller'; - /** the column name for the OPERATION field */ - const OPERATION = 'coupon_rule.OPERATION'; + /** the column name for the operation field */ + const OPERATION = 'coupon_rule.operation'; - /** the column name for the VALUE field */ - const VALUE = 'coupon_rule.VALUE'; + /** the column name for the value field */ + const VALUE = 'coupon_rule.value'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'coupon_rule.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'coupon_rule.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'coupon_rule.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'coupon_rule.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -187,13 +187,13 @@ abstract class BaseCouponRulePeer $criteria->addSelectColumn(CouponRulePeer::CREATED_AT); $criteria->addSelectColumn(CouponRulePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.COUPON_ID'); - $criteria->addSelectColumn($alias . '.CONTROLLER'); - $criteria->addSelectColumn($alias . '.OPERATION'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.coupon_id'); + $criteria->addSelectColumn($alias . '.controller'); + $criteria->addSelectColumn($alias . '.operation'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -277,7 +277,7 @@ abstract class BaseCouponRulePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -382,8 +382,15 @@ abstract class BaseCouponRulePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CouponRulePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CouponRulePeer::$instances = array(); } @@ -756,7 +763,7 @@ abstract class BaseCouponRulePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CouponRulePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php index 5258ebc08..f1cfc175c 100644 --- a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php @@ -49,7 +49,6 @@ use Thelia\Model\CouponRuleQuery; * @method CouponRule findOne(PropelPDO $con = null) Return the first CouponRule matching the query * @method CouponRule findOneOrCreate(PropelPDO $con = null) Return the first CouponRule matching the query, or a new CouponRule object populated from the query conditions when no match is found * - * @method CouponRule findOneById(int $id) Return the first CouponRule filtered by the id column * @method CouponRule findOneByCouponId(int $coupon_id) Return the first CouponRule filtered by the coupon_id column * @method CouponRule findOneByController(string $controller) Return the first CouponRule filtered by the controller column * @method CouponRule findOneByOperation(string $operation) Return the first CouponRule filtered by the operation column @@ -85,7 +84,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * Returns a new CouponRuleQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CouponRuleQuery|Criteria $criteria Optional Criteria to build the query from + * @param CouponRuleQuery|Criteria $criteria Optional Criteria to build the query from * * @return CouponRuleQuery */ @@ -141,6 +140,20 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CouponRule A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -148,12 +161,12 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CouponRule A model object, or null if the key is not found - * @throws PropelException + * @return CouponRule A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `COUPON_ID`, `CONTROLLER`, `OPERATION`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `coupon_rule` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `coupon_id`, `controller`, `operation`, `value`, `created_at`, `updated_at` FROM `coupon_rule` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -249,7 +262,8 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -262,8 +276,22 @@ abstract class BaseCouponRuleQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CouponRulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CouponRulePeer::ID, $id, $comparison); @@ -276,7 +304,8 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $query->filterByCouponId(1234); // WHERE coupon_id = 1234 * $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34) - * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12 + * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id >= 12 + * $query->filterByCouponId(array('max' => 12)); // WHERE coupon_id <= 12 * * * @see filterByCoupon() @@ -377,7 +406,8 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $query->filterByValue(1234); // WHERE value = 1234 * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 + * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 * * * @param mixed $value The value to use as filter. @@ -503,8 +533,8 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * @param Coupon|PropelObjectCollection $coupon The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CouponRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CouponRuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCoupon($coupon, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/om/BaseCurrency.php index 2e7958d96..137e18da3 100644 --- a/core/lib/Thelia/Model/om/BaseCurrency.php +++ b/core/lib/Thelia/Model/om/BaseCurrency.php @@ -117,6 +117,12 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -202,22 +208,25 @@ abstract class BaseCurrency extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -239,22 +248,25 @@ abstract class BaseCurrency extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -265,7 +277,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -286,7 +298,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setName($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -307,7 +319,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -328,7 +340,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setSymbol($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -349,7 +361,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setRate($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -370,7 +382,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function setByDefault($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -476,7 +488,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = CurrencyPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -688,7 +700,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($this->collOrders !== null) { foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -721,28 +733,28 @@ abstract class BaseCurrency extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CurrencyPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CurrencyPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`NAME`'; + $modifiedColumns[':p' . $index++] = '`name`'; } if ($this->isColumnModified(CurrencyPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(CurrencyPeer::SYMBOL)) { - $modifiedColumns[':p' . $index++] = '`SYMBOL`'; + $modifiedColumns[':p' . $index++] = '`symbol`'; } if ($this->isColumnModified(CurrencyPeer::RATE)) { - $modifiedColumns[':p' . $index++] = '`RATE`'; + $modifiedColumns[':p' . $index++] = '`rate`'; } if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; + $modifiedColumns[':p' . $index++] = '`by_default`'; } if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -755,28 +767,28 @@ abstract class BaseCurrency extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`NAME`': + case '`name`': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`SYMBOL`': + case '`symbol`': $stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR); break; - case '`RATE`': + case '`rate`': $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); break; - case '`BY_DEFAULT`': + case '`by_default`': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -847,11 +859,11 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1252,13 +1264,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Currency The current object (for fluent API support) * @see addOrders() */ public function clearOrders() { $this->collOrders = null; // important to set this to null since that means it is uninitialized $this->collOrdersPartial = null; + + return $this; } /** @@ -1330,6 +1344,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->collOrdersPartial = true; } + $collOrders->getInternalIterator()->rewind(); return $collOrders; } @@ -1357,12 +1372,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * * @param PropelCollection $orders A Propel collection. * @param PropelPDO $con Optional connection object + * @return Currency The current object (for fluent API support) */ public function setOrders(PropelCollection $orders, PropelPDO $con = null) { - $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders); + $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - foreach ($this->ordersScheduledForDeletion as $orderRemoved) { + $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setCurrency(null); } @@ -1373,6 +1391,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->collOrders = $orders; $this->collOrdersPartial = false; + + return $this; } /** @@ -1390,22 +1410,22 @@ abstract class BaseCurrency extends BaseObject implements Persistent if (null === $this->collOrders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCurrency($this) - ->count($con); } - } else { - return count($this->collOrders); + + if($partial && !$criteria) { + return count($this->getOrders()); + } + $query = OrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCurrency($this) + ->count($con); } + + return count($this->collOrders); } /** @@ -1421,7 +1441,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->initOrders(); $this->collOrdersPartial = true; } - if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrder($l); } @@ -1439,6 +1459,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * @param Order $order The order object to remove. + * @return Currency The current object (for fluent API support) */ public function removeOrder($order) { @@ -1451,6 +1472,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->ordersScheduledForDeletion[]= $order; $order->setCurrency(null); } + + return $this; } @@ -1568,6 +1591,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1585,12 +1609,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collOrders) { foreach ($this->collOrders as $o) { $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collOrders instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php index 11ec01f8f..5da12afbb 100644 --- a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php +++ b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php @@ -45,29 +45,29 @@ abstract class BaseCurrencyPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'currency.ID'; + /** the column name for the id field */ + const ID = 'currency.id'; - /** the column name for the NAME field */ - const NAME = 'currency.NAME'; + /** the column name for the name field */ + const NAME = 'currency.name'; - /** the column name for the CODE field */ - const CODE = 'currency.CODE'; + /** the column name for the code field */ + const CODE = 'currency.code'; - /** the column name for the SYMBOL field */ - const SYMBOL = 'currency.SYMBOL'; + /** the column name for the symbol field */ + const SYMBOL = 'currency.symbol'; - /** the column name for the RATE field */ - const RATE = 'currency.RATE'; + /** the column name for the rate field */ + const RATE = 'currency.rate'; - /** the column name for the BY_DEFAULT field */ - const BY_DEFAULT = 'currency.BY_DEFAULT'; + /** the column name for the by_default field */ + const BY_DEFAULT = 'currency.by_default'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'currency.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'currency.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'currency.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'currency.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -191,14 +191,14 @@ abstract class BaseCurrencyPeer $criteria->addSelectColumn(CurrencyPeer::CREATED_AT); $criteria->addSelectColumn(CurrencyPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.SYMBOL'); - $criteria->addSelectColumn($alias . '.RATE'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.symbol'); + $criteria->addSelectColumn($alias . '.rate'); + $criteria->addSelectColumn($alias . '.by_default'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -282,7 +282,7 @@ abstract class BaseCurrencyPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -387,8 +387,15 @@ abstract class BaseCurrencyPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CurrencyPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CurrencyPeer::$instances = array(); } @@ -526,7 +533,7 @@ abstract class BaseCurrencyPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CurrencyPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php index 819109902..7c202ec84 100644 --- a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php +++ b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php @@ -51,7 +51,6 @@ use Thelia\Model\Order; * @method Currency findOne(PropelPDO $con = null) Return the first Currency matching the query * @method Currency findOneOrCreate(PropelPDO $con = null) Return the first Currency matching the query, or a new Currency object populated from the query conditions when no match is found * - * @method Currency findOneById(int $id) Return the first Currency filtered by the id column * @method Currency findOneByName(string $name) Return the first Currency filtered by the name column * @method Currency findOneByCode(string $code) Return the first Currency filtered by the code column * @method Currency findOneBySymbol(string $symbol) Return the first Currency filtered by the symbol column @@ -89,7 +88,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * Returns a new CurrencyQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CurrencyQuery|Criteria $criteria Optional Criteria to build the query from + * @param CurrencyQuery|Criteria $criteria Optional Criteria to build the query from * * @return CurrencyQuery */ @@ -145,6 +144,20 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Currency A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -152,12 +165,12 @@ abstract class BaseCurrencyQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Currency A model object, or null if the key is not found - * @throws PropelException + * @return Currency A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `NAME`, `CODE`, `SYMBOL`, `RATE`, `BY_DEFAULT`, `CREATED_AT`, `UPDATED_AT` FROM `currency` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `name`, `code`, `symbol`, `rate`, `by_default`, `created_at`, `updated_at` FROM `currency` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -253,7 +266,8 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -266,8 +280,22 @@ abstract class BaseCurrencyQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CurrencyPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CurrencyPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CurrencyPeer::ID, $id, $comparison); @@ -367,7 +395,8 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $query->filterByRate(1234); // WHERE rate = 1234 * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34) - * $query->filterByRate(array('min' => 12)); // WHERE rate > 12 + * $query->filterByRate(array('min' => 12)); // WHERE rate >= 12 + * $query->filterByRate(array('max' => 12)); // WHERE rate <= 12 * * * @param mixed $rate The value to use as filter. @@ -408,7 +437,8 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $query->filterByByDefault(1234); // WHERE by_default = 1234 * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 + * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 * * * @param mixed $byDefault The value to use as filter. @@ -534,8 +564,8 @@ abstract class BaseCurrencyQuery extends ModelCriteria * @param Order|PropelObjectCollection $order the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CurrencyQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CurrencyQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrder($order, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/om/BaseCustomer.php index f86b8cabf..6935ed1ea 100644 --- a/core/lib/Thelia/Model/om/BaseCustomer.php +++ b/core/lib/Thelia/Model/om/BaseCustomer.php @@ -228,6 +228,12 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -479,22 +485,25 @@ abstract class BaseCustomer extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -516,22 +525,25 @@ abstract class BaseCustomer extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -542,7 +554,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -563,7 +575,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -584,7 +596,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setCustomerTitleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -609,7 +621,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setCompany($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -630,7 +642,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setFirstname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -651,7 +663,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setLastname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -672,7 +684,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setAddress1($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -693,7 +705,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setAddress2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -714,7 +726,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setAddress3($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -735,7 +747,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setZipcode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -756,7 +768,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setCity($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -777,7 +789,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setCountryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -798,7 +810,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setPhone($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -819,7 +831,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setCellphone($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -840,7 +852,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setEmail($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -861,7 +873,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setPassword($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -882,7 +894,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setAlgo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -903,7 +915,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setSalt($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -924,7 +936,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setReseller($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -945,7 +957,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setLang($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -966,7 +978,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setSponsor($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -987,7 +999,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function setDiscount($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -1109,7 +1121,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 24; // 24 = CustomerPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -1338,7 +1350,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($this->collAddresss !== null) { foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1355,7 +1367,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($this->collOrders !== null) { foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1388,76 +1400,76 @@ abstract class BaseCustomer extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CustomerPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CustomerPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`'; + $modifiedColumns[':p' . $index++] = '`customer_title_id`'; } if ($this->isColumnModified(CustomerPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`COMPANY`'; + $modifiedColumns[':p' . $index++] = '`company`'; } if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`FIRSTNAME`'; + $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(CustomerPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`LASTNAME`'; + $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(CustomerPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS1`'; + $modifiedColumns[':p' . $index++] = '`address1`'; } if ($this->isColumnModified(CustomerPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS2`'; + $modifiedColumns[':p' . $index++] = '`address2`'; } if ($this->isColumnModified(CustomerPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS3`'; + $modifiedColumns[':p' . $index++] = '`address3`'; } if ($this->isColumnModified(CustomerPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`ZIPCODE`'; + $modifiedColumns[':p' . $index++] = '`zipcode`'; } if ($this->isColumnModified(CustomerPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`CITY`'; + $modifiedColumns[':p' . $index++] = '`city`'; } if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`'; + $modifiedColumns[':p' . $index++] = '`country_id`'; } if ($this->isColumnModified(CustomerPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`PHONE`'; + $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(CustomerPeer::CELLPHONE)) { - $modifiedColumns[':p' . $index++] = '`CELLPHONE`'; + $modifiedColumns[':p' . $index++] = '`cellphone`'; } if ($this->isColumnModified(CustomerPeer::EMAIL)) { - $modifiedColumns[':p' . $index++] = '`EMAIL`'; + $modifiedColumns[':p' . $index++] = '`email`'; } if ($this->isColumnModified(CustomerPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`PASSWORD`'; + $modifiedColumns[':p' . $index++] = '`password`'; } if ($this->isColumnModified(CustomerPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`ALGO`'; + $modifiedColumns[':p' . $index++] = '`algo`'; } if ($this->isColumnModified(CustomerPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`SALT`'; + $modifiedColumns[':p' . $index++] = '`salt`'; } if ($this->isColumnModified(CustomerPeer::RESELLER)) { - $modifiedColumns[':p' . $index++] = '`RESELLER`'; + $modifiedColumns[':p' . $index++] = '`reseller`'; } if ($this->isColumnModified(CustomerPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`LANG`'; + $modifiedColumns[':p' . $index++] = '`lang`'; } if ($this->isColumnModified(CustomerPeer::SPONSOR)) { - $modifiedColumns[':p' . $index++] = '`SPONSOR`'; + $modifiedColumns[':p' . $index++] = '`sponsor`'; } if ($this->isColumnModified(CustomerPeer::DISCOUNT)) { - $modifiedColumns[':p' . $index++] = '`DISCOUNT`'; + $modifiedColumns[':p' . $index++] = '`discount`'; } if ($this->isColumnModified(CustomerPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -1470,76 +1482,76 @@ abstract class BaseCustomer extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`CUSTOMER_TITLE_ID`': + case '`customer_title_id`': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`COMPANY`': + case '`company`': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`FIRSTNAME`': + case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`LASTNAME`': + case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`ADDRESS1`': + case '`address1`': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`ADDRESS2`': + case '`address2`': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`ADDRESS3`': + case '`address3`': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`ZIPCODE`': + case '`zipcode`': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`CITY`': + case '`city`': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`COUNTRY_ID`': + case '`country_id`': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`PHONE`': + case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`CELLPHONE`': + case '`cellphone`': $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); break; - case '`EMAIL`': + case '`email`': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; - case '`PASSWORD`': + case '`password`': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; - case '`ALGO`': + case '`algo`': $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); break; - case '`SALT`': + case '`salt`': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; - case '`RESELLER`': + case '`reseller`': $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT); break; - case '`LANG`': + case '`lang`': $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); break; - case '`SPONSOR`': + case '`sponsor`': $stmt->bindValue($identifier, $this->sponsor, PDO::PARAM_STR); break; - case '`DISCOUNT`': + case '`discount`': $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -1610,11 +1622,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -2217,12 +2229,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent * Get the associated CustomerTitle object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return CustomerTitle The associated CustomerTitle object. * @throws PropelException */ - public function getCustomerTitle(PropelPDO $con = null) + public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { + if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2261,13 +2274,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Customer The current object (for fluent API support) * @see addAddresss() */ public function clearAddresss() { $this->collAddresss = null; // important to set this to null since that means it is uninitialized $this->collAddresssPartial = null; + + return $this; } /** @@ -2339,6 +2354,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->collAddresssPartial = true; } + $collAddresss->getInternalIterator()->rewind(); return $collAddresss; } @@ -2366,12 +2382,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * * @param PropelCollection $addresss A Propel collection. * @param PropelPDO $con Optional connection object + * @return Customer The current object (for fluent API support) */ public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) { - $this->addresssScheduledForDeletion = $this->getAddresss(new Criteria(), $con)->diff($addresss); + $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); - foreach ($this->addresssScheduledForDeletion as $addressRemoved) { + $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); + + foreach ($addresssToDelete as $addressRemoved) { $addressRemoved->setCustomer(null); } @@ -2382,6 +2401,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->collAddresss = $addresss; $this->collAddresssPartial = false; + + return $this; } /** @@ -2399,22 +2420,22 @@ abstract class BaseCustomer extends BaseObject implements Persistent if (null === $this->collAddresss || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAddresss) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAddresss()); - } - $query = AddressQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomer($this) - ->count($con); } - } else { - return count($this->collAddresss); + + if($partial && !$criteria) { + return count($this->getAddresss()); + } + $query = AddressQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomer($this) + ->count($con); } + + return count($this->collAddresss); } /** @@ -2430,7 +2451,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->initAddresss(); $this->collAddresssPartial = true; } - if (!$this->collAddresss->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAddress($l); } @@ -2448,6 +2469,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * @param Address $address The address object to remove. + * @return Customer The current object (for fluent API support) */ public function removeAddress($address) { @@ -2457,9 +2479,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->addresssScheduledForDeletion = clone $this->collAddresss; $this->addresssScheduledForDeletion->clear(); } - $this->addresssScheduledForDeletion[]= $address; + $this->addresssScheduledForDeletion[]= clone $address; $address->setCustomer(null); } + + return $this; } @@ -2493,13 +2517,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Customer The current object (for fluent API support) * @see addOrders() */ public function clearOrders() { $this->collOrders = null; // important to set this to null since that means it is uninitialized $this->collOrdersPartial = null; + + return $this; } /** @@ -2571,6 +2597,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->collOrdersPartial = true; } + $collOrders->getInternalIterator()->rewind(); return $collOrders; } @@ -2598,12 +2625,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * * @param PropelCollection $orders A Propel collection. * @param PropelPDO $con Optional connection object + * @return Customer The current object (for fluent API support) */ public function setOrders(PropelCollection $orders, PropelPDO $con = null) { - $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders); + $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - foreach ($this->ordersScheduledForDeletion as $orderRemoved) { + $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setCustomer(null); } @@ -2614,6 +2644,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->collOrders = $orders; $this->collOrdersPartial = false; + + return $this; } /** @@ -2631,22 +2663,22 @@ abstract class BaseCustomer extends BaseObject implements Persistent if (null === $this->collOrders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomer($this) - ->count($con); } - } else { - return count($this->collOrders); + + if($partial && !$criteria) { + return count($this->getOrders()); + } + $query = OrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomer($this) + ->count($con); } + + return count($this->collOrders); } /** @@ -2662,7 +2694,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->initOrders(); $this->collOrdersPartial = true; } - if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrder($l); } @@ -2680,6 +2712,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * @param Order $order The order object to remove. + * @return Customer The current object (for fluent API support) */ public function removeOrder($order) { @@ -2689,9 +2722,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->ordersScheduledForDeletion = clone $this->collOrders; $this->ordersScheduledForDeletion->clear(); } - $this->ordersScheduledForDeletion[]= $order; + $this->ordersScheduledForDeletion[]= clone $order; $order->setCustomer(null); } + + return $this; } @@ -2825,6 +2860,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2842,7 +2878,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAddresss) { foreach ($this->collAddresss as $o) { $o->clearAllReferences($deep); @@ -2853,6 +2890,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aCustomerTitle instanceof Persistent) { + $this->aCustomerTitle->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collAddresss instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseCustomerPeer.php b/core/lib/Thelia/Model/om/BaseCustomerPeer.php index 75448e400..6b30317fe 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerPeer.php +++ b/core/lib/Thelia/Model/om/BaseCustomerPeer.php @@ -47,77 +47,77 @@ abstract class BaseCustomerPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 24; - /** the column name for the ID field */ - const ID = 'customer.ID'; + /** the column name for the id field */ + const ID = 'customer.id'; - /** the column name for the REF field */ - const REF = 'customer.REF'; + /** the column name for the ref field */ + const REF = 'customer.ref'; - /** the column name for the CUSTOMER_TITLE_ID field */ - const CUSTOMER_TITLE_ID = 'customer.CUSTOMER_TITLE_ID'; + /** the column name for the customer_title_id field */ + const CUSTOMER_TITLE_ID = 'customer.customer_title_id'; - /** the column name for the COMPANY field */ - const COMPANY = 'customer.COMPANY'; + /** the column name for the company field */ + const COMPANY = 'customer.company'; - /** the column name for the FIRSTNAME field */ - const FIRSTNAME = 'customer.FIRSTNAME'; + /** the column name for the firstname field */ + const FIRSTNAME = 'customer.firstname'; - /** the column name for the LASTNAME field */ - const LASTNAME = 'customer.LASTNAME'; + /** the column name for the lastname field */ + const LASTNAME = 'customer.lastname'; - /** the column name for the ADDRESS1 field */ - const ADDRESS1 = 'customer.ADDRESS1'; + /** the column name for the address1 field */ + const ADDRESS1 = 'customer.address1'; - /** the column name for the ADDRESS2 field */ - const ADDRESS2 = 'customer.ADDRESS2'; + /** the column name for the address2 field */ + const ADDRESS2 = 'customer.address2'; - /** the column name for the ADDRESS3 field */ - const ADDRESS3 = 'customer.ADDRESS3'; + /** the column name for the address3 field */ + const ADDRESS3 = 'customer.address3'; - /** the column name for the ZIPCODE field */ - const ZIPCODE = 'customer.ZIPCODE'; + /** the column name for the zipcode field */ + const ZIPCODE = 'customer.zipcode'; - /** the column name for the CITY field */ - const CITY = 'customer.CITY'; + /** the column name for the city field */ + const CITY = 'customer.city'; - /** the column name for the COUNTRY_ID field */ - const COUNTRY_ID = 'customer.COUNTRY_ID'; + /** the column name for the country_id field */ + const COUNTRY_ID = 'customer.country_id'; - /** the column name for the PHONE field */ - const PHONE = 'customer.PHONE'; + /** the column name for the phone field */ + const PHONE = 'customer.phone'; - /** the column name for the CELLPHONE field */ - const CELLPHONE = 'customer.CELLPHONE'; + /** the column name for the cellphone field */ + const CELLPHONE = 'customer.cellphone'; - /** the column name for the EMAIL field */ - const EMAIL = 'customer.EMAIL'; + /** the column name for the email field */ + const EMAIL = 'customer.email'; - /** the column name for the PASSWORD field */ - const PASSWORD = 'customer.PASSWORD'; + /** the column name for the password field */ + const PASSWORD = 'customer.password'; - /** the column name for the ALGO field */ - const ALGO = 'customer.ALGO'; + /** the column name for the algo field */ + const ALGO = 'customer.algo'; - /** the column name for the SALT field */ - const SALT = 'customer.SALT'; + /** the column name for the salt field */ + const SALT = 'customer.salt'; - /** the column name for the RESELLER field */ - const RESELLER = 'customer.RESELLER'; + /** the column name for the reseller field */ + const RESELLER = 'customer.reseller'; - /** the column name for the LANG field */ - const LANG = 'customer.LANG'; + /** the column name for the lang field */ + const LANG = 'customer.lang'; - /** the column name for the SPONSOR field */ - const SPONSOR = 'customer.SPONSOR'; + /** the column name for the sponsor field */ + const SPONSOR = 'customer.sponsor'; - /** the column name for the DISCOUNT field */ - const DISCOUNT = 'customer.DISCOUNT'; + /** the column name for the discount field */ + const DISCOUNT = 'customer.discount'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'customer.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'customer.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'customer.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'customer.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -257,30 +257,30 @@ abstract class BaseCustomerPeer $criteria->addSelectColumn(CustomerPeer::CREATED_AT); $criteria->addSelectColumn(CustomerPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID'); - $criteria->addSelectColumn($alias . '.COMPANY'); - $criteria->addSelectColumn($alias . '.FIRSTNAME'); - $criteria->addSelectColumn($alias . '.LASTNAME'); - $criteria->addSelectColumn($alias . '.ADDRESS1'); - $criteria->addSelectColumn($alias . '.ADDRESS2'); - $criteria->addSelectColumn($alias . '.ADDRESS3'); - $criteria->addSelectColumn($alias . '.ZIPCODE'); - $criteria->addSelectColumn($alias . '.CITY'); - $criteria->addSelectColumn($alias . '.COUNTRY_ID'); - $criteria->addSelectColumn($alias . '.PHONE'); - $criteria->addSelectColumn($alias . '.CELLPHONE'); - $criteria->addSelectColumn($alias . '.EMAIL'); - $criteria->addSelectColumn($alias . '.PASSWORD'); - $criteria->addSelectColumn($alias . '.ALGO'); - $criteria->addSelectColumn($alias . '.SALT'); - $criteria->addSelectColumn($alias . '.RESELLER'); - $criteria->addSelectColumn($alias . '.LANG'); - $criteria->addSelectColumn($alias . '.SPONSOR'); - $criteria->addSelectColumn($alias . '.DISCOUNT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.customer_title_id'); + $criteria->addSelectColumn($alias . '.company'); + $criteria->addSelectColumn($alias . '.firstname'); + $criteria->addSelectColumn($alias . '.lastname'); + $criteria->addSelectColumn($alias . '.address1'); + $criteria->addSelectColumn($alias . '.address2'); + $criteria->addSelectColumn($alias . '.address3'); + $criteria->addSelectColumn($alias . '.zipcode'); + $criteria->addSelectColumn($alias . '.city'); + $criteria->addSelectColumn($alias . '.country_id'); + $criteria->addSelectColumn($alias . '.phone'); + $criteria->addSelectColumn($alias . '.cellphone'); + $criteria->addSelectColumn($alias . '.email'); + $criteria->addSelectColumn($alias . '.password'); + $criteria->addSelectColumn($alias . '.algo'); + $criteria->addSelectColumn($alias . '.salt'); + $criteria->addSelectColumn($alias . '.reseller'); + $criteria->addSelectColumn($alias . '.lang'); + $criteria->addSelectColumn($alias . '.sponsor'); + $criteria->addSelectColumn($alias . '.discount'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -364,7 +364,7 @@ abstract class BaseCustomerPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -469,8 +469,15 @@ abstract class BaseCustomerPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CustomerPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CustomerPeer::$instances = array(); } @@ -849,7 +856,7 @@ abstract class BaseCustomerPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CustomerPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/om/BaseCustomerQuery.php index f719d555b..7f839c024 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerQuery.php @@ -93,7 +93,6 @@ use Thelia\Model\Order; * @method Customer findOne(PropelPDO $con = null) Return the first Customer matching the query * @method Customer findOneOrCreate(PropelPDO $con = null) Return the first Customer matching the query, or a new Customer object populated from the query conditions when no match is found * - * @method Customer findOneById(int $id) Return the first Customer filtered by the id column * @method Customer findOneByRef(string $ref) Return the first Customer filtered by the ref column * @method Customer findOneByCustomerTitleId(int $customer_title_id) Return the first Customer filtered by the customer_title_id column * @method Customer findOneByCompany(string $company) Return the first Customer filtered by the company column @@ -163,7 +162,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * Returns a new CustomerQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CustomerQuery|Criteria $criteria Optional Criteria to build the query from + * @param CustomerQuery|Criteria $criteria Optional Criteria to build the query from * * @return CustomerQuery */ @@ -219,6 +218,20 @@ abstract class BaseCustomerQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Customer A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -226,12 +239,12 @@ abstract class BaseCustomerQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Customer A model object, or null if the key is not found - * @throws PropelException + * @return Customer A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `REF`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `COUNTRY_ID`, `PHONE`, `CELLPHONE`, `EMAIL`, `PASSWORD`, `ALGO`, `SALT`, `RESELLER`, `LANG`, `SPONSOR`, `DISCOUNT`, `CREATED_AT`, `UPDATED_AT` FROM `customer` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `ref`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `country_id`, `phone`, `cellphone`, `email`, `password`, `algo`, `salt`, `reseller`, `lang`, `sponsor`, `discount`, `created_at`, `updated_at` FROM `customer` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -327,7 +340,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -340,8 +354,22 @@ abstract class BaseCustomerQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CustomerPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CustomerPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CustomerPeer::ID, $id, $comparison); @@ -383,7 +411,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 + * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 * * * @see filterByCustomerTitle() @@ -658,7 +687,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $query->filterByCountryId(1234); // WHERE country_id = 1234 * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 + * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 * * * @param mixed $countryId The value to use as filter. @@ -873,7 +903,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $query->filterByReseller(1234); // WHERE reseller = 1234 * $query->filterByReseller(array(12, 34)); // WHERE reseller IN (12, 34) - * $query->filterByReseller(array('min' => 12)); // WHERE reseller > 12 + * $query->filterByReseller(array('min' => 12)); // WHERE reseller >= 12 + * $query->filterByReseller(array('max' => 12)); // WHERE reseller <= 12 * * * @param mixed $reseller The value to use as filter. @@ -972,7 +1003,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $query->filterByDiscount(1234); // WHERE discount = 1234 * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34) - * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12 + * $query->filterByDiscount(array('min' => 12)); // WHERE discount >= 12 + * $query->filterByDiscount(array('max' => 12)); // WHERE discount <= 12 * * * @param mixed $discount The value to use as filter. @@ -1098,8 +1130,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomerTitle($customerTitle, $comparison = null) { @@ -1174,8 +1206,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * @param Address|PropelObjectCollection $address the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAddress($address, $comparison = null) { @@ -1248,8 +1280,8 @@ abstract class BaseCustomerQuery extends ModelCriteria * @param Order|PropelObjectCollection $order the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrder($order, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/om/BaseCustomerTitle.php index 228982fcd..3d1967579 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitle.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitle.php @@ -116,13 +116,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -218,22 +224,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -255,22 +264,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -281,7 +293,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -302,7 +314,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function setByDefault($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -323,7 +335,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -430,7 +442,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -646,7 +658,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($this->collCustomers !== null) { foreach ($this->collCustomers as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -664,7 +676,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($this->collAddresss !== null) { foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -681,7 +693,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($this->collCustomerTitleI18ns !== null) { foreach ($this->collCustomerTitleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -714,19 +726,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CustomerTitlePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; + $modifiedColumns[':p' . $index++] = '`by_default`'; } if ($this->isColumnModified(CustomerTitlePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -739,19 +751,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`BY_DEFAULT`': + case '`by_default`': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -822,11 +834,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1237,13 +1249,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return CustomerTitle The current object (for fluent API support) * @see addCustomers() */ public function clearCustomers() { $this->collCustomers = null; // important to set this to null since that means it is uninitialized $this->collCustomersPartial = null; + + return $this; } /** @@ -1315,6 +1329,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collCustomersPartial = true; } + $collCustomers->getInternalIterator()->rewind(); return $collCustomers; } @@ -1342,12 +1357,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @param PropelCollection $customers A Propel collection. * @param PropelPDO $con Optional connection object + * @return CustomerTitle The current object (for fluent API support) */ public function setCustomers(PropelCollection $customers, PropelPDO $con = null) { - $this->customersScheduledForDeletion = $this->getCustomers(new Criteria(), $con)->diff($customers); + $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers); - foreach ($this->customersScheduledForDeletion as $customerRemoved) { + $this->customersScheduledForDeletion = unserialize(serialize($customersToDelete)); + + foreach ($customersToDelete as $customerRemoved) { $customerRemoved->setCustomerTitle(null); } @@ -1358,6 +1376,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collCustomers = $customers; $this->collCustomersPartial = false; + + return $this; } /** @@ -1375,22 +1395,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if (null === $this->collCustomers || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCustomers) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCustomers()); - } - $query = CustomerQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); } - } else { - return count($this->collCustomers); + + if($partial && !$criteria) { + return count($this->getCustomers()); + } + $query = CustomerQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerTitle($this) + ->count($con); } + + return count($this->collCustomers); } /** @@ -1406,7 +1426,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->initCustomers(); $this->collCustomersPartial = true; } - if (!$this->collCustomers->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCustomer($l); } @@ -1424,6 +1444,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * @param Customer $customer The customer object to remove. + * @return CustomerTitle The current object (for fluent API support) */ public function removeCustomer($customer) { @@ -1436,6 +1457,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->customersScheduledForDeletion[]= $customer; $customer->setCustomerTitle(null); } + + return $this; } /** @@ -1444,13 +1467,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return CustomerTitle The current object (for fluent API support) * @see addAddresss() */ public function clearAddresss() { $this->collAddresss = null; // important to set this to null since that means it is uninitialized $this->collAddresssPartial = null; + + return $this; } /** @@ -1522,6 +1547,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collAddresssPartial = true; } + $collAddresss->getInternalIterator()->rewind(); return $collAddresss; } @@ -1549,12 +1575,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @param PropelCollection $addresss A Propel collection. * @param PropelPDO $con Optional connection object + * @return CustomerTitle The current object (for fluent API support) */ public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) { - $this->addresssScheduledForDeletion = $this->getAddresss(new Criteria(), $con)->diff($addresss); + $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); - foreach ($this->addresssScheduledForDeletion as $addressRemoved) { + $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); + + foreach ($addresssToDelete as $addressRemoved) { $addressRemoved->setCustomerTitle(null); } @@ -1565,6 +1594,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collAddresss = $addresss; $this->collAddresssPartial = false; + + return $this; } /** @@ -1582,22 +1613,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if (null === $this->collAddresss || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAddresss) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAddresss()); - } - $query = AddressQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); } - } else { - return count($this->collAddresss); + + if($partial && !$criteria) { + return count($this->getAddresss()); + } + $query = AddressQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerTitle($this) + ->count($con); } + + return count($this->collAddresss); } /** @@ -1613,7 +1644,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->initAddresss(); $this->collAddresssPartial = true; } - if (!$this->collAddresss->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAddress($l); } @@ -1631,6 +1662,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * @param Address $address The address object to remove. + * @return CustomerTitle The current object (for fluent API support) */ public function removeAddress($address) { @@ -1643,6 +1675,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->addresssScheduledForDeletion[]= $address; $address->setCustomerTitle(null); } + + return $this; } @@ -1676,13 +1710,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return CustomerTitle The current object (for fluent API support) * @see addCustomerTitleI18ns() */ public function clearCustomerTitleI18ns() { $this->collCustomerTitleI18ns = null; // important to set this to null since that means it is uninitialized $this->collCustomerTitleI18nsPartial = null; + + return $this; } /** @@ -1754,6 +1790,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collCustomerTitleI18nsPartial = true; } + $collCustomerTitleI18ns->getInternalIterator()->rewind(); return $collCustomerTitleI18ns; } @@ -1781,12 +1818,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @param PropelCollection $customerTitleI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return CustomerTitle The current object (for fluent API support) */ public function setCustomerTitleI18ns(PropelCollection $customerTitleI18ns, PropelPDO $con = null) { - $this->customerTitleI18nsScheduledForDeletion = $this->getCustomerTitleI18ns(new Criteria(), $con)->diff($customerTitleI18ns); + $customerTitleI18nsToDelete = $this->getCustomerTitleI18ns(new Criteria(), $con)->diff($customerTitleI18ns); - foreach ($this->customerTitleI18nsScheduledForDeletion as $customerTitleI18nRemoved) { + $this->customerTitleI18nsScheduledForDeletion = unserialize(serialize($customerTitleI18nsToDelete)); + + foreach ($customerTitleI18nsToDelete as $customerTitleI18nRemoved) { $customerTitleI18nRemoved->setCustomerTitle(null); } @@ -1797,6 +1837,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->collCustomerTitleI18ns = $customerTitleI18ns; $this->collCustomerTitleI18nsPartial = false; + + return $this; } /** @@ -1814,22 +1856,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCustomerTitleI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCustomerTitleI18ns()); - } - $query = CustomerTitleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); } - } else { - return count($this->collCustomerTitleI18ns); + + if($partial && !$criteria) { + return count($this->getCustomerTitleI18ns()); + } + $query = CustomerTitleI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerTitle($this) + ->count($con); } + + return count($this->collCustomerTitleI18ns); } /** @@ -1849,7 +1891,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->initCustomerTitleI18ns(); $this->collCustomerTitleI18nsPartial = true; } - if (!$this->collCustomerTitleI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCustomerTitleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCustomerTitleI18n($l); } @@ -1867,6 +1909,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to remove. + * @return CustomerTitle The current object (for fluent API support) */ public function removeCustomerTitleI18n($customerTitleI18n) { @@ -1876,9 +1919,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->customerTitleI18nsScheduledForDeletion = clone $this->collCustomerTitleI18ns; $this->customerTitleI18nsScheduledForDeletion->clear(); } - $this->customerTitleI18nsScheduledForDeletion[]= $customerTitleI18n; + $this->customerTitleI18nsScheduledForDeletion[]= clone $customerTitleI18n; $customerTitleI18n->setCustomerTitle(null); } + + return $this; } /** @@ -1893,6 +1938,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1911,7 +1957,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collCustomers) { foreach ($this->collCustomers as $o) { $o->clearAllReferences($deep); @@ -1927,10 +1974,12 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collCustomers instanceof PropelCollection) { @@ -1990,7 +2039,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @return CustomerTitle The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2014,7 +2063,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return CustomerTitleI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCustomerTitleI18ns) { @@ -2049,7 +2098,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @return CustomerTitle The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { CustomerTitleI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php index 9300900b0..0f1cf83e0 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php @@ -53,7 +53,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -89,6 +89,12 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -97,7 +103,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -158,7 +164,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -183,7 +189,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -204,7 +210,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function setShort($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -225,7 +231,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function setLong($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -248,7 +254,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -285,7 +291,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -511,16 +517,16 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CustomerTitleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(CustomerTitleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(CustomerTitleI18nPeer::SHORT)) { - $modifiedColumns[':p' . $index++] = '`SHORT`'; + $modifiedColumns[':p' . $index++] = '`short`'; } if ($this->isColumnModified(CustomerTitleI18nPeer::LONG)) { - $modifiedColumns[':p' . $index++] = '`LONG`'; + $modifiedColumns[':p' . $index++] = '`long`'; } $sql = sprintf( @@ -533,16 +539,16 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`SHORT`': + case '`short`': $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR); break; - case '`LONG`': + case '`long`': $stmt->bindValue($identifier, $this->long, PDO::PARAM_STR); break; } @@ -606,11 +612,11 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -986,12 +992,13 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent * Get the associated CustomerTitle object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return CustomerTitle The associated CustomerTitle object. * @throws PropelException */ - public function getCustomerTitle(PropelPDO $con = null) + public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) { - if ($this->aCustomerTitle === null && ($this->id !== null)) { + if ($this->aCustomerTitle === null && ($this->id !== null) && $doQuery) { $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1016,6 +1023,7 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent $this->long = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1034,7 +1042,13 @@ abstract class BaseCustomerTitleI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCustomerTitle instanceof Persistent) { + $this->aCustomerTitle->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCustomerTitle = null; diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php index b41d8d2c7..93a40f1a4 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php @@ -45,17 +45,17 @@ abstract class BaseCustomerTitleI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'customer_title_i18n.ID'; + /** the column name for the id field */ + const ID = 'customer_title_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'customer_title_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'customer_title_i18n.locale'; - /** the column name for the SHORT field */ - const SHORT = 'customer_title_i18n.SHORT'; + /** the column name for the short field */ + const SHORT = 'customer_title_i18n.short'; - /** the column name for the LONG field */ - const LONG = 'customer_title_i18n.LONG'; + /** the column name for the long field */ + const LONG = 'customer_title_i18n.long'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -175,10 +175,10 @@ abstract class BaseCustomerTitleI18nPeer $criteria->addSelectColumn(CustomerTitleI18nPeer::SHORT); $criteria->addSelectColumn(CustomerTitleI18nPeer::LONG); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.SHORT'); - $criteria->addSelectColumn($alias . '.LONG'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.short'); + $criteria->addSelectColumn($alias . '.long'); } } @@ -262,7 +262,7 @@ abstract class BaseCustomerTitleI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -367,8 +367,15 @@ abstract class BaseCustomerTitleI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CustomerTitleI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CustomerTitleI18nPeer::$instances = array(); } @@ -741,7 +748,7 @@ abstract class BaseCustomerTitleI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CustomerTitleI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php index cf667572f..027989714 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php @@ -73,7 +73,7 @@ abstract class BaseCustomerTitleI18nQuery extends ModelCriteria * Returns a new CustomerTitleI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CustomerTitleI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param CustomerTitleI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return CustomerTitleI18nQuery */ @@ -137,12 +137,12 @@ abstract class BaseCustomerTitleI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CustomerTitleI18n A model object, or null if the key is not found - * @throws PropelException + * @return CustomerTitleI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `SHORT`, `LONG` FROM `customer_title_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `short`, `long` FROM `customer_title_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -250,7 +250,8 @@ abstract class BaseCustomerTitleI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByCustomerTitle() @@ -265,8 +266,22 @@ abstract class BaseCustomerTitleI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id, $comparison); @@ -365,8 +380,8 @@ abstract class BaseCustomerTitleI18nQuery extends ModelCriteria * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerTitleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerTitleI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomerTitle($customerTitle, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php index cf125cf8d..ef52d8a06 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php @@ -46,20 +46,20 @@ abstract class BaseCustomerTitlePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'customer_title.ID'; + /** the column name for the id field */ + const ID = 'customer_title.id'; - /** the column name for the BY_DEFAULT field */ - const BY_DEFAULT = 'customer_title.BY_DEFAULT'; + /** the column name for the by_default field */ + const BY_DEFAULT = 'customer_title.by_default'; - /** the column name for the POSITION field */ - const POSITION = 'customer_title.POSITION'; + /** the column name for the position field */ + const POSITION = 'customer_title.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'customer_title.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'customer_title.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'customer_title.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'customer_title.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -79,7 +79,7 @@ abstract class BaseCustomerTitlePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -187,11 +187,11 @@ abstract class BaseCustomerTitlePeer $criteria->addSelectColumn(CustomerTitlePeer::CREATED_AT); $criteria->addSelectColumn(CustomerTitlePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.by_default'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -275,7 +275,7 @@ abstract class BaseCustomerTitlePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -380,8 +380,15 @@ abstract class BaseCustomerTitlePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (CustomerTitlePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } CustomerTitlePeer::$instances = array(); } @@ -522,7 +529,7 @@ abstract class BaseCustomerTitlePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return CustomerTitlePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php index a55adc984..d35f91f22 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php @@ -55,7 +55,6 @@ use Thelia\Model\CustomerTitleQuery; * @method CustomerTitle findOne(PropelPDO $con = null) Return the first CustomerTitle matching the query * @method CustomerTitle findOneOrCreate(PropelPDO $con = null) Return the first CustomerTitle matching the query, or a new CustomerTitle object populated from the query conditions when no match is found * - * @method CustomerTitle findOneById(int $id) Return the first CustomerTitle filtered by the id column * @method CustomerTitle findOneByByDefault(int $by_default) Return the first CustomerTitle filtered by the by_default column * @method CustomerTitle findOneByPosition(string $position) Return the first CustomerTitle filtered by the position column * @method CustomerTitle findOneByCreatedAt(string $created_at) Return the first CustomerTitle filtered by the created_at column @@ -87,7 +86,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * Returns a new CustomerTitleQuery object. * * @param string $modelAlias The alias of a model in the query - * @param CustomerTitleQuery|Criteria $criteria Optional Criteria to build the query from + * @param CustomerTitleQuery|Criteria $criteria Optional Criteria to build the query from * * @return CustomerTitleQuery */ @@ -143,6 +142,20 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CustomerTitle A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -150,12 +163,12 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return CustomerTitle A model object, or null if the key is not found - * @throws PropelException + * @return CustomerTitle A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `BY_DEFAULT`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `customer_title` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `by_default`, `position`, `created_at`, `updated_at` FROM `customer_title` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -251,7 +264,8 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -264,8 +278,22 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CustomerTitlePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CustomerTitlePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(CustomerTitlePeer::ID, $id, $comparison); @@ -278,7 +306,8 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * $query->filterByByDefault(1234); // WHERE by_default = 1234 * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 + * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 * * * @param mixed $byDefault The value to use as filter. @@ -433,8 +462,8 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @param Customer|PropelObjectCollection $customer the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerTitleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomer($customer, $comparison = null) { @@ -507,8 +536,8 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @param Address|PropelObjectCollection $address the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerTitleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAddress($address, $comparison = null) { @@ -581,8 +610,8 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @param CustomerTitleI18n|PropelObjectCollection $customerTitleI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return CustomerTitleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomerTitleI18n($customerTitleI18n, $comparison = null) { @@ -741,7 +770,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @return CustomerTitleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; @@ -759,7 +788,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @return CustomerTitleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -780,7 +809,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @return CustomerTitleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseDelivzone.php b/core/lib/Thelia/Model/om/BaseDelivzone.php index 1ae77190e..0e19dcde3 100644 --- a/core/lib/Thelia/Model/om/BaseDelivzone.php +++ b/core/lib/Thelia/Model/om/BaseDelivzone.php @@ -96,6 +96,12 @@ abstract class BaseDelivzone extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -145,22 +151,25 @@ abstract class BaseDelivzone extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -182,22 +191,25 @@ abstract class BaseDelivzone extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -208,7 +220,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -229,7 +241,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent */ public function setAreaId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -254,7 +266,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent */ public function setDelivery($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -357,7 +369,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = DelivzonePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -598,19 +610,19 @@ abstract class BaseDelivzone extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(DelivzonePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(DelivzonePeer::AREA_ID)) { - $modifiedColumns[':p' . $index++] = '`AREA_ID`'; + $modifiedColumns[':p' . $index++] = '`area_id`'; } if ($this->isColumnModified(DelivzonePeer::DELIVERY)) { - $modifiedColumns[':p' . $index++] = '`DELIVERY`'; + $modifiedColumns[':p' . $index++] = '`delivery`'; } if ($this->isColumnModified(DelivzonePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(DelivzonePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -623,19 +635,19 @@ abstract class BaseDelivzone extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`AREA_ID`': + case '`area_id`': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case '`DELIVERY`': + case '`delivery`': $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -706,11 +718,11 @@ abstract class BaseDelivzone extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1089,12 +1101,13 @@ abstract class BaseDelivzone extends BaseObject implements Persistent * Get the associated Area object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Area The associated Area object. * @throws PropelException */ - public function getArea(PropelPDO $con = null) + public function getArea(PropelPDO $con = null, $doQuery = true) { - if ($this->aArea === null && ($this->area_id !== null)) { + if ($this->aArea === null && ($this->area_id !== null) && $doQuery) { $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1120,6 +1133,7 @@ abstract class BaseDelivzone extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1137,7 +1151,13 @@ abstract class BaseDelivzone extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aArea instanceof Persistent) { + $this->aArea->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aArea = null; diff --git a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php index c2cbaf9a0..51f1d1b54 100644 --- a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php +++ b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php @@ -45,20 +45,20 @@ abstract class BaseDelivzonePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'delivzone.ID'; + /** the column name for the id field */ + const ID = 'delivzone.id'; - /** the column name for the AREA_ID field */ - const AREA_ID = 'delivzone.AREA_ID'; + /** the column name for the area_id field */ + const AREA_ID = 'delivzone.area_id'; - /** the column name for the DELIVERY field */ - const DELIVERY = 'delivzone.DELIVERY'; + /** the column name for the delivery field */ + const DELIVERY = 'delivzone.delivery'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'delivzone.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'delivzone.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'delivzone.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'delivzone.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -179,11 +179,11 @@ abstract class BaseDelivzonePeer $criteria->addSelectColumn(DelivzonePeer::CREATED_AT); $criteria->addSelectColumn(DelivzonePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.AREA_ID'); - $criteria->addSelectColumn($alias . '.DELIVERY'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.area_id'); + $criteria->addSelectColumn($alias . '.delivery'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -267,7 +267,7 @@ abstract class BaseDelivzonePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -372,8 +372,15 @@ abstract class BaseDelivzonePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (DelivzonePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } DelivzonePeer::$instances = array(); } @@ -746,7 +753,7 @@ abstract class BaseDelivzonePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return DelivzonePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php index 9f6bb4e06..93f87df2c 100644 --- a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php +++ b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php @@ -45,7 +45,6 @@ use Thelia\Model\DelivzoneQuery; * @method Delivzone findOne(PropelPDO $con = null) Return the first Delivzone matching the query * @method Delivzone findOneOrCreate(PropelPDO $con = null) Return the first Delivzone matching the query, or a new Delivzone object populated from the query conditions when no match is found * - * @method Delivzone findOneById(int $id) Return the first Delivzone filtered by the id column * @method Delivzone findOneByAreaId(int $area_id) Return the first Delivzone filtered by the area_id column * @method Delivzone findOneByDelivery(string $delivery) Return the first Delivzone filtered by the delivery column * @method Delivzone findOneByCreatedAt(string $created_at) Return the first Delivzone filtered by the created_at column @@ -77,7 +76,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * Returns a new DelivzoneQuery object. * * @param string $modelAlias The alias of a model in the query - * @param DelivzoneQuery|Criteria $criteria Optional Criteria to build the query from + * @param DelivzoneQuery|Criteria $criteria Optional Criteria to build the query from * * @return DelivzoneQuery */ @@ -133,6 +132,20 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Delivzone A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -140,12 +153,12 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Delivzone A model object, or null if the key is not found - * @throws PropelException + * @return Delivzone A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `AREA_ID`, `DELIVERY`, `CREATED_AT`, `UPDATED_AT` FROM `delivzone` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `area_id`, `delivery`, `created_at`, `updated_at` FROM `delivzone` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -241,7 +254,8 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -254,8 +268,22 @@ abstract class BaseDelivzoneQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(DelivzonePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(DelivzonePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(DelivzonePeer::ID, $id, $comparison); @@ -268,7 +296,8 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * $query->filterByAreaId(1234); // WHERE area_id = 1234 * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) - * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id >= 12 + * $query->filterByAreaId(array('max' => 12)); // WHERE area_id <= 12 * * * @see filterByArea() @@ -425,8 +454,8 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * @param Area|PropelObjectCollection $area The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DelivzoneQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DelivzoneQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByArea($area, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/om/BaseDocument.php index 4c29f793a..c13846285 100644 --- a/core/lib/Thelia/Model/om/BaseDocument.php +++ b/core/lib/Thelia/Model/om/BaseDocument.php @@ -151,13 +151,19 @@ abstract class BaseDocument extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -260,22 +266,25 @@ abstract class BaseDocument extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -297,22 +306,25 @@ abstract class BaseDocument extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -323,7 +335,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -344,7 +356,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -369,7 +381,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -394,7 +406,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setFolderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -419,7 +431,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setContentId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -444,7 +456,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setFile($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -465,7 +477,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -572,7 +584,7 @@ abstract class BaseDocument extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 9; // 9 = DocumentPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -832,7 +844,7 @@ abstract class BaseDocument extends BaseObject implements Persistent if ($this->collDocumentI18ns !== null) { foreach ($this->collDocumentI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -865,31 +877,31 @@ abstract class BaseDocument extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(DocumentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`FOLDER_ID`'; + $modifiedColumns[':p' . $index++] = '`folder_id`'; } if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`CONTENT_ID`'; + $modifiedColumns[':p' . $index++] = '`content_id`'; } if ($this->isColumnModified(DocumentPeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`FILE`'; + $modifiedColumns[':p' . $index++] = '`file`'; } if ($this->isColumnModified(DocumentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(DocumentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -902,31 +914,31 @@ abstract class BaseDocument extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`FOLDER_ID`': + case '`folder_id`': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`CONTENT_ID`': + case '`content_id`': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`FILE`': + case '`file`': $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -997,11 +1009,11 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1464,12 +1476,13 @@ abstract class BaseDocument extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1515,12 +1528,13 @@ abstract class BaseDocument extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1566,12 +1580,13 @@ abstract class BaseDocument extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->content_id !== null)) { + if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1617,12 +1632,13 @@ abstract class BaseDocument extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->folder_id !== null)) { + if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1658,13 +1674,15 @@ abstract class BaseDocument extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Document The current object (for fluent API support) * @see addDocumentI18ns() */ public function clearDocumentI18ns() { $this->collDocumentI18ns = null; // important to set this to null since that means it is uninitialized $this->collDocumentI18nsPartial = null; + + return $this; } /** @@ -1736,6 +1754,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->collDocumentI18nsPartial = true; } + $collDocumentI18ns->getInternalIterator()->rewind(); return $collDocumentI18ns; } @@ -1763,12 +1782,15 @@ abstract class BaseDocument extends BaseObject implements Persistent * * @param PropelCollection $documentI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Document The current object (for fluent API support) */ public function setDocumentI18ns(PropelCollection $documentI18ns, PropelPDO $con = null) { - $this->documentI18nsScheduledForDeletion = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns); + $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns); - foreach ($this->documentI18nsScheduledForDeletion as $documentI18nRemoved) { + $this->documentI18nsScheduledForDeletion = unserialize(serialize($documentI18nsToDelete)); + + foreach ($documentI18nsToDelete as $documentI18nRemoved) { $documentI18nRemoved->setDocument(null); } @@ -1779,6 +1801,8 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->collDocumentI18ns = $documentI18ns; $this->collDocumentI18nsPartial = false; + + return $this; } /** @@ -1796,22 +1820,22 @@ abstract class BaseDocument extends BaseObject implements Persistent if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocumentI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDocumentI18ns()); - } - $query = DocumentI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByDocument($this) - ->count($con); } - } else { - return count($this->collDocumentI18ns); + + if($partial && !$criteria) { + return count($this->getDocumentI18ns()); + } + $query = DocumentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByDocument($this) + ->count($con); } + + return count($this->collDocumentI18ns); } /** @@ -1831,7 +1855,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->initDocumentI18ns(); $this->collDocumentI18nsPartial = true; } - if (!$this->collDocumentI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDocumentI18n($l); } @@ -1849,6 +1873,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * @param DocumentI18n $documentI18n The documentI18n object to remove. + * @return Document The current object (for fluent API support) */ public function removeDocumentI18n($documentI18n) { @@ -1858,9 +1883,11 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->documentI18nsScheduledForDeletion = clone $this->collDocumentI18ns; $this->documentI18nsScheduledForDeletion->clear(); } - $this->documentI18nsScheduledForDeletion[]= $documentI18n; + $this->documentI18nsScheduledForDeletion[]= clone $documentI18n; $documentI18n->setDocument(null); } + + return $this; } /** @@ -1879,6 +1906,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1896,16 +1924,31 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collDocumentI18ns) { foreach ($this->collDocumentI18ns as $o) { $o->clearAllReferences($deep); } } + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collDocumentI18ns instanceof PropelCollection) { @@ -1961,7 +2004,7 @@ abstract class BaseDocument extends BaseObject implements Persistent * * @return Document The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1985,7 +2028,7 @@ abstract class BaseDocument extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return DocumentI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collDocumentI18ns) { @@ -2020,7 +2063,7 @@ abstract class BaseDocument extends BaseObject implements Persistent * * @return Document The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { DocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18n.php b/core/lib/Thelia/Model/om/BaseDocumentI18n.php index 5b13d65c3..19b93544b 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentI18n.php +++ b/core/lib/Thelia/Model/om/BaseDocumentI18n.php @@ -53,7 +53,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = DocumentI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(DocumentI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(DocumentI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(DocumentI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(DocumentI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(DocumentI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(DocumentI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent * Get the associated Document object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Document The associated Document object. * @throws PropelException */ - public function getDocument(PropelPDO $con = null) + public function getDocument(PropelPDO $con = null, $doQuery = true) { - if ($this->aDocument === null && ($this->id !== null)) { + if ($this->aDocument === null && ($this->id !== null) && $doQuery) { $this->aDocument = DocumentQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseDocumentI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aDocument instanceof Persistent) { + $this->aDocument->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aDocument = null; diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php b/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php index 0b5dbaad9..e59601028 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseDocumentI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'document_i18n.ID'; + /** the column name for the id field */ + const ID = 'document_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'document_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'document_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'document_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'document_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'document_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'document_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'document_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'document_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'document_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'document_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseDocumentI18nPeer $criteria->addSelectColumn(DocumentI18nPeer::CHAPO); $criteria->addSelectColumn(DocumentI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseDocumentI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseDocumentI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (DocumentI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } DocumentI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseDocumentI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return DocumentI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php b/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php index 489474b02..307471f35 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * Returns a new DocumentI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param DocumentI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param DocumentI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return DocumentI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return DocumentI18n A model object, or null if the key is not found - * @throws PropelException + * @return DocumentI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `document_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `document_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByDocument() @@ -273,8 +274,22 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(DocumentI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(DocumentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(DocumentI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * @param Document|PropelObjectCollection $document The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocument($document, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseDocumentPeer.php b/core/lib/Thelia/Model/om/BaseDocumentPeer.php index c3d4ab54d..5025124d7 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentPeer.php +++ b/core/lib/Thelia/Model/om/BaseDocumentPeer.php @@ -49,32 +49,32 @@ abstract class BaseDocumentPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 9; - /** the column name for the ID field */ - const ID = 'document.ID'; + /** the column name for the id field */ + const ID = 'document.id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'document.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'document.product_id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'document.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'document.category_id'; - /** the column name for the FOLDER_ID field */ - const FOLDER_ID = 'document.FOLDER_ID'; + /** the column name for the folder_id field */ + const FOLDER_ID = 'document.folder_id'; - /** the column name for the CONTENT_ID field */ - const CONTENT_ID = 'document.CONTENT_ID'; + /** the column name for the content_id field */ + const CONTENT_ID = 'document.content_id'; - /** the column name for the FILE field */ - const FILE = 'document.FILE'; + /** the column name for the file field */ + const FILE = 'document.file'; - /** the column name for the POSITION field */ - const POSITION = 'document.POSITION'; + /** the column name for the position field */ + const POSITION = 'document.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'document.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'document.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'document.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'document.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -94,7 +94,7 @@ abstract class BaseDocumentPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -206,15 +206,15 @@ abstract class BaseDocumentPeer $criteria->addSelectColumn(DocumentPeer::CREATED_AT); $criteria->addSelectColumn(DocumentPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.FILE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.folder_id'); + $criteria->addSelectColumn($alias . '.content_id'); + $criteria->addSelectColumn($alias . '.file'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -298,7 +298,7 @@ abstract class BaseDocumentPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -403,8 +403,15 @@ abstract class BaseDocumentPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (DocumentPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } DocumentPeer::$instances = array(); } @@ -1917,7 +1924,7 @@ abstract class BaseDocumentPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return DocumentPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/om/BaseDocumentQuery.php index da5ed9889..5e5f95712 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentQuery.php +++ b/core/lib/Thelia/Model/om/BaseDocumentQuery.php @@ -73,7 +73,6 @@ use Thelia\Model\Product; * @method Document findOne(PropelPDO $con = null) Return the first Document matching the query * @method Document findOneOrCreate(PropelPDO $con = null) Return the first Document matching the query, or a new Document object populated from the query conditions when no match is found * - * @method Document findOneById(int $id) Return the first Document filtered by the id column * @method Document findOneByProductId(int $product_id) Return the first Document filtered by the product_id column * @method Document findOneByCategoryId(int $category_id) Return the first Document filtered by the category_id column * @method Document findOneByFolderId(int $folder_id) Return the first Document filtered by the folder_id column @@ -113,7 +112,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * Returns a new DocumentQuery object. * * @param string $modelAlias The alias of a model in the query - * @param DocumentQuery|Criteria $criteria Optional Criteria to build the query from + * @param DocumentQuery|Criteria $criteria Optional Criteria to build the query from * * @return DocumentQuery */ @@ -169,6 +168,20 @@ abstract class BaseDocumentQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Document A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -176,12 +189,12 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Document A model object, or null if the key is not found - * @throws PropelException + * @return Document A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `document` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `product_id`, `category_id`, `folder_id`, `content_id`, `file`, `position`, `created_at`, `updated_at` FROM `document` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -277,7 +290,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -290,8 +304,22 @@ abstract class BaseDocumentQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(DocumentPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(DocumentPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(DocumentPeer::ID, $id, $comparison); @@ -304,7 +332,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -347,7 +376,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -390,7 +420,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterByFolderId(1234); // WHERE folder_id = 1234 * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 + * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 * * * @see filterByFolder() @@ -433,7 +464,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterByContentId(1234); // WHERE content_id = 1234 * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 + * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 * * * @see filterByContent() @@ -505,7 +537,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -631,8 +664,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -707,8 +740,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -783,8 +816,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { @@ -859,8 +892,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { @@ -935,8 +968,8 @@ abstract class BaseDocumentQuery extends ModelCriteria * @param DocumentI18n|PropelObjectCollection $documentI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return DocumentQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocumentI18n($documentI18n, $comparison = null) { @@ -1095,7 +1128,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @return DocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'DocumentI18n'; @@ -1113,7 +1146,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @return DocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1134,7 +1167,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @return DocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/om/BaseFeature.php index df0ca3bae..e2d0cb206 100644 --- a/core/lib/Thelia/Model/om/BaseFeature.php +++ b/core/lib/Thelia/Model/om/BaseFeature.php @@ -124,13 +124,19 @@ abstract class BaseFeature extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -232,22 +238,25 @@ abstract class BaseFeature extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -269,22 +278,25 @@ abstract class BaseFeature extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -295,7 +307,7 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -316,7 +328,7 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -337,7 +349,7 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -444,7 +456,7 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = FeaturePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -661,7 +673,7 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->collFeatureAvs !== null) { foreach ($this->collFeatureAvs as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -678,7 +690,7 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->collFeatureProds !== null) { foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -695,7 +707,7 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->collFeatureCategorys !== null) { foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -712,7 +724,7 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->collFeatureI18ns !== null) { foreach ($this->collFeatureI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -745,19 +757,19 @@ abstract class BaseFeature extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeaturePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeaturePeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(FeaturePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(FeaturePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -770,19 +782,19 @@ abstract class BaseFeature extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -853,11 +865,11 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1288,13 +1300,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Feature The current object (for fluent API support) * @see addFeatureAvs() */ public function clearFeatureAvs() { $this->collFeatureAvs = null; // important to set this to null since that means it is uninitialized $this->collFeatureAvsPartial = null; + + return $this; } /** @@ -1366,6 +1380,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureAvsPartial = true; } + $collFeatureAvs->getInternalIterator()->rewind(); return $collFeatureAvs; } @@ -1393,12 +1408,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @param PropelCollection $featureAvs A Propel collection. * @param PropelPDO $con Optional connection object + * @return Feature The current object (for fluent API support) */ public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null) { - $this->featureAvsScheduledForDeletion = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs); + $featureAvsToDelete = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs); - foreach ($this->featureAvsScheduledForDeletion as $featureAvRemoved) { + $this->featureAvsScheduledForDeletion = unserialize(serialize($featureAvsToDelete)); + + foreach ($featureAvsToDelete as $featureAvRemoved) { $featureAvRemoved->setFeature(null); } @@ -1409,6 +1427,8 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureAvs = $featureAvs; $this->collFeatureAvsPartial = false; + + return $this; } /** @@ -1426,22 +1446,22 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null === $this->collFeatureAvs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureAvs) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureAvs()); - } - $query = FeatureAvQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); } - } else { - return count($this->collFeatureAvs); + + if($partial && !$criteria) { + return count($this->getFeatureAvs()); + } + $query = FeatureAvQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeature($this) + ->count($con); } + + return count($this->collFeatureAvs); } /** @@ -1457,7 +1477,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->initFeatureAvs(); $this->collFeatureAvsPartial = true; } - if (!$this->collFeatureAvs->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureAv($l); } @@ -1475,6 +1495,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * @param FeatureAv $featureAv The featureAv object to remove. + * @return Feature The current object (for fluent API support) */ public function removeFeatureAv($featureAv) { @@ -1484,9 +1505,11 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs; $this->featureAvsScheduledForDeletion->clear(); } - $this->featureAvsScheduledForDeletion[]= $featureAv; + $this->featureAvsScheduledForDeletion[]= clone $featureAv; $featureAv->setFeature(null); } + + return $this; } /** @@ -1495,13 +1518,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Feature The current object (for fluent API support) * @see addFeatureProds() */ public function clearFeatureProds() { $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized $this->collFeatureProdsPartial = null; + + return $this; } /** @@ -1573,6 +1598,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureProdsPartial = true; } + $collFeatureProds->getInternalIterator()->rewind(); return $collFeatureProds; } @@ -1600,12 +1626,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @param PropelCollection $featureProds A Propel collection. * @param PropelPDO $con Optional connection object + * @return Feature The current object (for fluent API support) */ public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) { - $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); + $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { + $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setFeature(null); } @@ -1616,6 +1645,8 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureProds = $featureProds; $this->collFeatureProdsPartial = false; + + return $this; } /** @@ -1633,22 +1664,22 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null === $this->collFeatureProds || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureProds) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); } - } else { - return count($this->collFeatureProds); + + if($partial && !$criteria) { + return count($this->getFeatureProds()); + } + $query = FeatureProdQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeature($this) + ->count($con); } + + return count($this->collFeatureProds); } /** @@ -1664,7 +1695,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->initFeatureProds(); $this->collFeatureProdsPartial = true; } - if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureProd($l); } @@ -1682,6 +1713,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * @param FeatureProd $featureProd The featureProd object to remove. + * @return Feature The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -1691,9 +1723,11 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; $this->featureProdsScheduledForDeletion->clear(); } - $this->featureProdsScheduledForDeletion[]= $featureProd; + $this->featureProdsScheduledForDeletion[]= clone $featureProd; $featureProd->setFeature(null); } + + return $this; } @@ -1752,13 +1786,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Feature The current object (for fluent API support) * @see addFeatureCategorys() */ public function clearFeatureCategorys() { $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized $this->collFeatureCategorysPartial = null; + + return $this; } /** @@ -1830,6 +1866,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureCategorysPartial = true; } + $collFeatureCategorys->getInternalIterator()->rewind(); return $collFeatureCategorys; } @@ -1857,12 +1894,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @param PropelCollection $featureCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Feature The current object (for fluent API support) */ public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) { - $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); + $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); - foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) { + $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); + + foreach ($featureCategorysToDelete as $featureCategoryRemoved) { $featureCategoryRemoved->setFeature(null); } @@ -1873,6 +1913,8 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureCategorys = $featureCategorys; $this->collFeatureCategorysPartial = false; + + return $this; } /** @@ -1890,22 +1932,22 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); - } - $query = FeatureCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); } - } else { - return count($this->collFeatureCategorys); + + if($partial && !$criteria) { + return count($this->getFeatureCategorys()); + } + $query = FeatureCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeature($this) + ->count($con); } + + return count($this->collFeatureCategorys); } /** @@ -1921,7 +1963,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->initFeatureCategorys(); $this->collFeatureCategorysPartial = true; } - if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureCategory($l); } @@ -1939,6 +1981,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * @param FeatureCategory $featureCategory The featureCategory object to remove. + * @return Feature The current object (for fluent API support) */ public function removeFeatureCategory($featureCategory) { @@ -1948,9 +1991,11 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; $this->featureCategorysScheduledForDeletion->clear(); } - $this->featureCategorysScheduledForDeletion[]= $featureCategory; + $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; $featureCategory->setFeature(null); } + + return $this; } @@ -1984,13 +2029,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Feature The current object (for fluent API support) * @see addFeatureI18ns() */ public function clearFeatureI18ns() { $this->collFeatureI18ns = null; // important to set this to null since that means it is uninitialized $this->collFeatureI18nsPartial = null; + + return $this; } /** @@ -2062,6 +2109,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureI18nsPartial = true; } + $collFeatureI18ns->getInternalIterator()->rewind(); return $collFeatureI18ns; } @@ -2089,12 +2137,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @param PropelCollection $featureI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Feature The current object (for fluent API support) */ public function setFeatureI18ns(PropelCollection $featureI18ns, PropelPDO $con = null) { - $this->featureI18nsScheduledForDeletion = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns); + $featureI18nsToDelete = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns); - foreach ($this->featureI18nsScheduledForDeletion as $featureI18nRemoved) { + $this->featureI18nsScheduledForDeletion = unserialize(serialize($featureI18nsToDelete)); + + foreach ($featureI18nsToDelete as $featureI18nRemoved) { $featureI18nRemoved->setFeature(null); } @@ -2105,6 +2156,8 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureI18ns = $featureI18ns; $this->collFeatureI18nsPartial = false; + + return $this; } /** @@ -2122,22 +2175,22 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null === $this->collFeatureI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureI18ns()); - } - $query = FeatureI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); } - } else { - return count($this->collFeatureI18ns); + + if($partial && !$criteria) { + return count($this->getFeatureI18ns()); + } + $query = FeatureI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeature($this) + ->count($con); } + + return count($this->collFeatureI18ns); } /** @@ -2157,7 +2210,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->initFeatureI18ns(); $this->collFeatureI18nsPartial = true; } - if (!$this->collFeatureI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureI18n($l); } @@ -2175,6 +2228,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * @param FeatureI18n $featureI18n The featureI18n object to remove. + * @return Feature The current object (for fluent API support) */ public function removeFeatureI18n($featureI18n) { @@ -2184,9 +2238,11 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->featureI18nsScheduledForDeletion = clone $this->collFeatureI18ns; $this->featureI18nsScheduledForDeletion->clear(); } - $this->featureI18nsScheduledForDeletion[]= $featureI18n; + $this->featureI18nsScheduledForDeletion[]= clone $featureI18n; $featureI18n->setFeature(null); } + + return $this; } /** @@ -2201,6 +2257,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -2219,7 +2276,8 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collFeatureAvs) { foreach ($this->collFeatureAvs as $o) { $o->clearAllReferences($deep); @@ -2240,10 +2298,12 @@ abstract class BaseFeature extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collFeatureAvs instanceof PropelCollection) { @@ -2307,7 +2367,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @return Feature The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2331,7 +2391,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return FeatureI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureI18ns) { @@ -2366,7 +2426,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @return Feature The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { FeatureI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/om/BaseFeatureAv.php index 878301627..adaffcd44 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAv.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAv.php @@ -108,13 +108,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -173,22 +179,25 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -210,22 +219,25 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -236,7 +248,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -257,7 +269,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function setFeatureId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -363,7 +375,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = FeatureAvPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -593,7 +605,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($this->collFeatureProds !== null) { foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -610,7 +622,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($this->collFeatureAvI18ns !== null) { foreach ($this->collFeatureAvI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -643,16 +655,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeatureAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_ID`'; + $modifiedColumns[':p' . $index++] = '`feature_id`'; } if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -665,16 +677,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`FEATURE_ID`': + case '`feature_id`': $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -745,11 +757,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1152,12 +1164,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * Get the associated Feature object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Feature The associated Feature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null) + public function getFeature(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeature === null && ($this->feature_id !== null)) { + if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1196,13 +1209,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return FeatureAv The current object (for fluent API support) * @see addFeatureProds() */ public function clearFeatureProds() { $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized $this->collFeatureProdsPartial = null; + + return $this; } /** @@ -1274,6 +1289,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->collFeatureProdsPartial = true; } + $collFeatureProds->getInternalIterator()->rewind(); return $collFeatureProds; } @@ -1301,12 +1317,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * @param PropelCollection $featureProds A Propel collection. * @param PropelPDO $con Optional connection object + * @return FeatureAv The current object (for fluent API support) */ public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) { - $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); + $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { + $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setFeatureAv(null); } @@ -1317,6 +1336,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->collFeatureProds = $featureProds; $this->collFeatureProdsPartial = false; + + return $this; } /** @@ -1334,22 +1355,22 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if (null === $this->collFeatureProds || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureProds) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeatureAv($this) - ->count($con); } - } else { - return count($this->collFeatureProds); + + if($partial && !$criteria) { + return count($this->getFeatureProds()); + } + $query = FeatureProdQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeatureAv($this) + ->count($con); } + + return count($this->collFeatureProds); } /** @@ -1365,7 +1386,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->initFeatureProds(); $this->collFeatureProdsPartial = true; } - if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureProd($l); } @@ -1383,6 +1404,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * @param FeatureProd $featureProd The featureProd object to remove. + * @return FeatureAv The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -1395,6 +1417,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->featureProdsScheduledForDeletion[]= $featureProd; $featureProd->setFeatureAv(null); } + + return $this; } @@ -1453,13 +1477,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return FeatureAv The current object (for fluent API support) * @see addFeatureAvI18ns() */ public function clearFeatureAvI18ns() { $this->collFeatureAvI18ns = null; // important to set this to null since that means it is uninitialized $this->collFeatureAvI18nsPartial = null; + + return $this; } /** @@ -1531,6 +1557,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->collFeatureAvI18nsPartial = true; } + $collFeatureAvI18ns->getInternalIterator()->rewind(); return $collFeatureAvI18ns; } @@ -1558,12 +1585,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * @param PropelCollection $featureAvI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return FeatureAv The current object (for fluent API support) */ public function setFeatureAvI18ns(PropelCollection $featureAvI18ns, PropelPDO $con = null) { - $this->featureAvI18nsScheduledForDeletion = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns); + $featureAvI18nsToDelete = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns); - foreach ($this->featureAvI18nsScheduledForDeletion as $featureAvI18nRemoved) { + $this->featureAvI18nsScheduledForDeletion = unserialize(serialize($featureAvI18nsToDelete)); + + foreach ($featureAvI18nsToDelete as $featureAvI18nRemoved) { $featureAvI18nRemoved->setFeatureAv(null); } @@ -1574,6 +1604,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->collFeatureAvI18ns = $featureAvI18ns; $this->collFeatureAvI18nsPartial = false; + + return $this; } /** @@ -1591,22 +1623,22 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureAvI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureAvI18ns()); - } - $query = FeatureAvI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeatureAv($this) - ->count($con); } - } else { - return count($this->collFeatureAvI18ns); + + if($partial && !$criteria) { + return count($this->getFeatureAvI18ns()); + } + $query = FeatureAvI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeatureAv($this) + ->count($con); } + + return count($this->collFeatureAvI18ns); } /** @@ -1626,7 +1658,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->initFeatureAvI18ns(); $this->collFeatureAvI18nsPartial = true; } - if (!$this->collFeatureAvI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureAvI18n($l); } @@ -1644,6 +1676,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove. + * @return FeatureAv The current object (for fluent API support) */ public function removeFeatureAvI18n($featureAvI18n) { @@ -1653,9 +1686,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->featureAvI18nsScheduledForDeletion = clone $this->collFeatureAvI18ns; $this->featureAvI18nsScheduledForDeletion->clear(); } - $this->featureAvI18nsScheduledForDeletion[]= $featureAvI18n; + $this->featureAvI18nsScheduledForDeletion[]= clone $featureAvI18n; $featureAvI18n->setFeatureAv(null); } + + return $this; } /** @@ -1669,6 +1704,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1686,7 +1722,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collFeatureProds) { foreach ($this->collFeatureProds as $o) { $o->clearAllReferences($deep); @@ -1697,10 +1734,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aFeature instanceof Persistent) { + $this->aFeature->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collFeatureProds instanceof PropelCollection) { @@ -1757,7 +1799,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * @return FeatureAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1781,7 +1823,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return FeatureAvI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureAvI18ns) { @@ -1816,7 +1858,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * @return FeatureAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { FeatureAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php index 95e6c2c57..5860ad6dc 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php @@ -53,7 +53,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = FeatureAvI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeatureAvI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeatureAvI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(FeatureAvI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(FeatureAvI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(FeatureAvI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(FeatureAvI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent * Get the associated FeatureAv object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return FeatureAv The associated FeatureAv object. * @throws PropelException */ - public function getFeatureAv(PropelPDO $con = null) + public function getFeatureAv(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeatureAv === null && ($this->id !== null)) { + if ($this->aFeatureAv === null && ($this->id !== null) && $doQuery) { $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseFeatureAvI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aFeatureAv instanceof Persistent) { + $this->aFeatureAv->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aFeatureAv = null; diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php index 64413df0f..c4144fd24 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseFeatureAvI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'feature_av_i18n.ID'; + /** the column name for the id field */ + const ID = 'feature_av_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'feature_av_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'feature_av_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'feature_av_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'feature_av_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'feature_av_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'feature_av_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'feature_av_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'feature_av_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'feature_av_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'feature_av_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseFeatureAvI18nPeer $criteria->addSelectColumn(FeatureAvI18nPeer::CHAPO); $criteria->addSelectColumn(FeatureAvI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseFeatureAvI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseFeatureAvI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeatureAvI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeatureAvI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseFeatureAvI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeatureAvI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php index 63c706961..f305575dc 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * Returns a new FeatureAvI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureAvI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureAvI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureAvI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FeatureAvI18n A model object, or null if the key is not found - * @throws PropelException + * @return FeatureAvI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `feature_av_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_av_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByFeatureAv() @@ -273,8 +274,22 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeatureAvI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeatureAvI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeatureAvI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureAvI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureAvI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureAv($featureAv, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php index 0c3deb687..e565a43e0 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php @@ -47,17 +47,17 @@ abstract class BaseFeatureAvPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'feature_av.ID'; + /** the column name for the id field */ + const ID = 'feature_av.id'; - /** the column name for the FEATURE_ID field */ - const FEATURE_ID = 'feature_av.FEATURE_ID'; + /** the column name for the feature_id field */ + const FEATURE_ID = 'feature_av.feature_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'feature_av.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'feature_av.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'feature_av.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'feature_av.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -77,7 +77,7 @@ abstract class BaseFeatureAvPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -184,10 +184,10 @@ abstract class BaseFeatureAvPeer $criteria->addSelectColumn(FeatureAvPeer::CREATED_AT); $criteria->addSelectColumn(FeatureAvPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FEATURE_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.feature_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -271,7 +271,7 @@ abstract class BaseFeatureAvPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -376,8 +376,15 @@ abstract class BaseFeatureAvPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeatureAvPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeatureAvPeer::$instances = array(); } @@ -756,7 +763,7 @@ abstract class BaseFeatureAvPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeatureAvPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php index 8824bc418..98f1fd0e4 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php @@ -53,7 +53,6 @@ use Thelia\Model\FeatureProd; * @method FeatureAv findOne(PropelPDO $con = null) Return the first FeatureAv matching the query * @method FeatureAv findOneOrCreate(PropelPDO $con = null) Return the first FeatureAv matching the query, or a new FeatureAv object populated from the query conditions when no match is found * - * @method FeatureAv findOneById(int $id) Return the first FeatureAv filtered by the id column * @method FeatureAv findOneByFeatureId(int $feature_id) Return the first FeatureAv filtered by the feature_id column * @method FeatureAv findOneByCreatedAt(string $created_at) Return the first FeatureAv filtered by the created_at column * @method FeatureAv findOneByUpdatedAt(string $updated_at) Return the first FeatureAv filtered by the updated_at column @@ -83,7 +82,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * Returns a new FeatureAvQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureAvQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureAvQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureAvQuery */ @@ -139,6 +138,20 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return FeatureAv A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -146,12 +159,12 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FeatureAv A model object, or null if the key is not found - * @throws PropelException + * @return FeatureAv A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `FEATURE_ID`, `CREATED_AT`, `UPDATED_AT` FROM `feature_av` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `feature_id`, `created_at`, `updated_at` FROM `feature_av` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -247,7 +260,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -260,8 +274,22 @@ abstract class BaseFeatureAvQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeatureAvPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeatureAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeatureAvPeer::ID, $id, $comparison); @@ -274,7 +302,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 + * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 * * * @see filterByFeature() @@ -402,8 +431,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeature($feature, $comparison = null) { @@ -478,8 +507,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureProd($featureProd, $comparison = null) { @@ -552,8 +581,8 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @param FeatureAvI18n|PropelObjectCollection $featureAvI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureAvQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureAvI18n($featureAvI18n, $comparison = null) { @@ -712,7 +741,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @return FeatureAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; @@ -730,7 +759,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @return FeatureAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -751,7 +780,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @return FeatureAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategory.php b/core/lib/Thelia/Model/om/BaseFeatureCategory.php index 351438774..ffdd4ef02 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureCategory.php +++ b/core/lib/Thelia/Model/om/BaseFeatureCategory.php @@ -103,6 +103,12 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -152,22 +158,25 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -189,22 +198,25 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -215,7 +227,7 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -236,7 +248,7 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent */ public function setFeatureId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -261,7 +273,7 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -368,7 +380,7 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -620,19 +632,19 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeatureCategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeatureCategoryPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_ID`'; + $modifiedColumns[':p' . $index++] = '`feature_id`'; } if ($this->isColumnModified(FeatureCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -645,19 +657,19 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`FEATURE_ID`': + case '`feature_id`': $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -728,11 +740,11 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1120,12 +1132,13 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1171,12 +1184,13 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent * Get the associated Feature object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Feature The associated Feature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null) + public function getFeature(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeature === null && ($this->feature_id !== null)) { + if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1202,6 +1216,7 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1219,7 +1234,16 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aFeature instanceof Persistent) { + $this->aFeature->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCategory = null; diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php index bbd78d2a6..2dfa0e579 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php @@ -46,20 +46,20 @@ abstract class BaseFeatureCategoryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'feature_category.ID'; + /** the column name for the id field */ + const ID = 'feature_category.id'; - /** the column name for the FEATURE_ID field */ - const FEATURE_ID = 'feature_category.FEATURE_ID'; + /** the column name for the feature_id field */ + const FEATURE_ID = 'feature_category.feature_id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'feature_category.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'feature_category.category_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'feature_category.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'feature_category.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'feature_category.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'feature_category.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -180,11 +180,11 @@ abstract class BaseFeatureCategoryPeer $criteria->addSelectColumn(FeatureCategoryPeer::CREATED_AT); $criteria->addSelectColumn(FeatureCategoryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FEATURE_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.feature_id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -268,7 +268,7 @@ abstract class BaseFeatureCategoryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -373,8 +373,15 @@ abstract class BaseFeatureCategoryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeatureCategoryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeatureCategoryPeer::$instances = array(); } @@ -1140,7 +1147,7 @@ abstract class BaseFeatureCategoryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeatureCategoryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php index cfb16be58..f0481ff21 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php @@ -50,7 +50,6 @@ use Thelia\Model\FeatureCategoryQuery; * @method FeatureCategory findOne(PropelPDO $con = null) Return the first FeatureCategory matching the query * @method FeatureCategory findOneOrCreate(PropelPDO $con = null) Return the first FeatureCategory matching the query, or a new FeatureCategory object populated from the query conditions when no match is found * - * @method FeatureCategory findOneById(int $id) Return the first FeatureCategory filtered by the id column * @method FeatureCategory findOneByFeatureId(int $feature_id) Return the first FeatureCategory filtered by the feature_id column * @method FeatureCategory findOneByCategoryId(int $category_id) Return the first FeatureCategory filtered by the category_id column * @method FeatureCategory findOneByCreatedAt(string $created_at) Return the first FeatureCategory filtered by the created_at column @@ -82,7 +81,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * Returns a new FeatureCategoryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureCategoryQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureCategoryQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureCategoryQuery */ @@ -138,6 +137,20 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return FeatureCategory A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FeatureCategory A model object, or null if the key is not found - * @throws PropelException + * @return FeatureCategory A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `FEATURE_ID`, `CATEGORY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `feature_category` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `feature_id`, `category_id`, `created_at`, `updated_at` FROM `feature_category` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeatureCategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeatureCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeatureCategoryPeer::ID, $id, $comparison); @@ -273,7 +301,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 + * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 * * * @see filterByFeature() @@ -316,7 +345,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -444,8 +474,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -520,8 +550,8 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeature($feature, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18n.php b/core/lib/Thelia/Model/om/BaseFeatureI18n.php index 1fed9873f..5a18b0ade 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureI18n.php +++ b/core/lib/Thelia/Model/om/BaseFeatureI18n.php @@ -53,7 +53,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = FeatureI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeatureI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeatureI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(FeatureI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(FeatureI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(FeatureI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(FeatureI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent * Get the associated Feature object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Feature The associated Feature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null) + public function getFeature(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeature === null && ($this->id !== null)) { + if ($this->aFeature === null && ($this->id !== null) && $doQuery) { $this->aFeature = FeatureQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseFeatureI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aFeature instanceof Persistent) { + $this->aFeature->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aFeature = null; diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php b/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php index d83a5cc56..38d7a6f4d 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseFeatureI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'feature_i18n.ID'; + /** the column name for the id field */ + const ID = 'feature_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'feature_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'feature_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'feature_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'feature_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'feature_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'feature_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'feature_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'feature_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'feature_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'feature_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseFeatureI18nPeer $criteria->addSelectColumn(FeatureI18nPeer::CHAPO); $criteria->addSelectColumn(FeatureI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseFeatureI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseFeatureI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeatureI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeatureI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseFeatureI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeatureI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php b/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php index af5b6385e..d07e8d108 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * Returns a new FeatureI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FeatureI18n A model object, or null if the key is not found - * @throws PropelException + * @return FeatureI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `feature_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByFeature() @@ -273,8 +274,22 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeatureI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeatureI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeatureI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeature($feature, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseFeaturePeer.php b/core/lib/Thelia/Model/om/BaseFeaturePeer.php index 07435699f..954bb2e0e 100644 --- a/core/lib/Thelia/Model/om/BaseFeaturePeer.php +++ b/core/lib/Thelia/Model/om/BaseFeaturePeer.php @@ -48,20 +48,20 @@ abstract class BaseFeaturePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'feature.ID'; + /** the column name for the id field */ + const ID = 'feature.id'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'feature.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'feature.visible'; - /** the column name for the POSITION field */ - const POSITION = 'feature.POSITION'; + /** the column name for the position field */ + const POSITION = 'feature.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'feature.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'feature.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'feature.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'feature.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -81,7 +81,7 @@ abstract class BaseFeaturePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -189,11 +189,11 @@ abstract class BaseFeaturePeer $criteria->addSelectColumn(FeaturePeer::CREATED_AT); $criteria->addSelectColumn(FeaturePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -277,7 +277,7 @@ abstract class BaseFeaturePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -382,8 +382,15 @@ abstract class BaseFeaturePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeaturePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeaturePeer::$instances = array(); } @@ -530,7 +537,7 @@ abstract class BaseFeaturePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeaturePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/om/BaseFeatureProd.php index 62e2fcd4d..68d6f9ce0 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProd.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProd.php @@ -128,6 +128,12 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -207,22 +213,25 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -244,22 +253,25 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -270,7 +282,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -291,7 +303,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -316,7 +328,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setFeatureId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -341,7 +353,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setFeatureAvId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -366,7 +378,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setByDefault($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -387,7 +399,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -493,7 +505,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = FeatureProdPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -756,28 +768,28 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FeatureProdPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_ID`'; + $modifiedColumns[':p' . $index++] = '`feature_id`'; } if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_AV_ID`'; + $modifiedColumns[':p' . $index++] = '`feature_av_id`'; } if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; + $modifiedColumns[':p' . $index++] = '`by_default`'; } if ($this->isColumnModified(FeatureProdPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -790,28 +802,28 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`FEATURE_ID`': + case '`feature_id`': $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); break; - case '`FEATURE_AV_ID`': + case '`feature_av_id`': $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); break; - case '`BY_DEFAULT`': + case '`by_default`': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -882,11 +894,11 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1313,12 +1325,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1364,12 +1377,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * Get the associated Feature object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Feature The associated Feature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null) + public function getFeature(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeature === null && ($this->feature_id !== null)) { + if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1415,12 +1429,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * Get the associated FeatureAv object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return FeatureAv The associated FeatureAv object. * @throws PropelException */ - public function getFeatureAv(PropelPDO $con = null) + public function getFeatureAv(PropelPDO $con = null, $doQuery = true) { - if ($this->aFeatureAv === null && ($this->feature_av_id !== null)) { + if ($this->aFeatureAv === null && ($this->feature_av_id !== null) && $doQuery) { $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->feature_av_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1449,6 +1464,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1466,7 +1482,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aFeature instanceof Persistent) { + $this->aFeature->clearAllReferences($deep); + } + if ($this->aFeatureAv instanceof Persistent) { + $this->aFeatureAv->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php index d17925d3b..38323da0e 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php @@ -47,29 +47,29 @@ abstract class BaseFeatureProdPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'feature_prod.ID'; + /** the column name for the id field */ + const ID = 'feature_prod.id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'feature_prod.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'feature_prod.product_id'; - /** the column name for the FEATURE_ID field */ - const FEATURE_ID = 'feature_prod.FEATURE_ID'; + /** the column name for the feature_id field */ + const FEATURE_ID = 'feature_prod.feature_id'; - /** the column name for the FEATURE_AV_ID field */ - const FEATURE_AV_ID = 'feature_prod.FEATURE_AV_ID'; + /** the column name for the feature_av_id field */ + const FEATURE_AV_ID = 'feature_prod.feature_av_id'; - /** the column name for the BY_DEFAULT field */ - const BY_DEFAULT = 'feature_prod.BY_DEFAULT'; + /** the column name for the by_default field */ + const BY_DEFAULT = 'feature_prod.by_default'; - /** the column name for the POSITION field */ - const POSITION = 'feature_prod.POSITION'; + /** the column name for the position field */ + const POSITION = 'feature_prod.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'feature_prod.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'feature_prod.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'feature_prod.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'feature_prod.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -193,14 +193,14 @@ abstract class BaseFeatureProdPeer $criteria->addSelectColumn(FeatureProdPeer::CREATED_AT); $criteria->addSelectColumn(FeatureProdPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.FEATURE_ID'); - $criteria->addSelectColumn($alias . '.FEATURE_AV_ID'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.feature_id'); + $criteria->addSelectColumn($alias . '.feature_av_id'); + $criteria->addSelectColumn($alias . '.by_default'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -284,7 +284,7 @@ abstract class BaseFeatureProdPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -389,8 +389,15 @@ abstract class BaseFeatureProdPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FeatureProdPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FeatureProdPeer::$instances = array(); } @@ -1502,7 +1509,7 @@ abstract class BaseFeatureProdPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FeatureProdPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php index 8242d8c5f..761bacb44 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php @@ -61,7 +61,6 @@ use Thelia\Model\Product; * @method FeatureProd findOne(PropelPDO $con = null) Return the first FeatureProd matching the query * @method FeatureProd findOneOrCreate(PropelPDO $con = null) Return the first FeatureProd matching the query, or a new FeatureProd object populated from the query conditions when no match is found * - * @method FeatureProd findOneById(int $id) Return the first FeatureProd filtered by the id column * @method FeatureProd findOneByProductId(int $product_id) Return the first FeatureProd filtered by the product_id column * @method FeatureProd findOneByFeatureId(int $feature_id) Return the first FeatureProd filtered by the feature_id column * @method FeatureProd findOneByFeatureAvId(int $feature_av_id) Return the first FeatureProd filtered by the feature_av_id column @@ -99,7 +98,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * Returns a new FeatureProdQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureProdQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureProdQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureProdQuery */ @@ -155,6 +154,20 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return FeatureProd A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -162,12 +175,12 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FeatureProd A model object, or null if the key is not found - * @throws PropelException + * @return FeatureProd A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `FEATURE_ID`, `FEATURE_AV_ID`, `BY_DEFAULT`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `feature_prod` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `product_id`, `feature_id`, `feature_av_id`, `by_default`, `position`, `created_at`, `updated_at` FROM `feature_prod` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -263,7 +276,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -276,8 +290,22 @@ abstract class BaseFeatureProdQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeatureProdPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeatureProdPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeatureProdPeer::ID, $id, $comparison); @@ -290,7 +318,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -333,7 +362,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 + * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 * * * @see filterByFeature() @@ -376,7 +406,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234 * $query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34) - * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12 + * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id >= 12 + * $query->filterByFeatureAvId(array('max' => 12)); // WHERE feature_av_id <= 12 * * * @see filterByFeatureAv() @@ -448,7 +479,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -574,8 +606,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureProdQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -650,8 +682,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureProdQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeature($feature, $comparison = null) { @@ -726,8 +758,8 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureProdQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureAv($featureAv, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/om/BaseFeatureQuery.php index af50d2c1d..2aabaed24 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureQuery.php @@ -60,7 +60,6 @@ use Thelia\Model\FeatureQuery; * @method Feature findOne(PropelPDO $con = null) Return the first Feature matching the query * @method Feature findOneOrCreate(PropelPDO $con = null) Return the first Feature matching the query, or a new Feature object populated from the query conditions when no match is found * - * @method Feature findOneById(int $id) Return the first Feature filtered by the id column * @method Feature findOneByVisible(int $visible) Return the first Feature filtered by the visible column * @method Feature findOneByPosition(int $position) Return the first Feature filtered by the position column * @method Feature findOneByCreatedAt(string $created_at) Return the first Feature filtered by the created_at column @@ -92,7 +91,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * Returns a new FeatureQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FeatureQuery|Criteria $criteria Optional Criteria to build the query from + * @param FeatureQuery|Criteria $criteria Optional Criteria to build the query from * * @return FeatureQuery */ @@ -148,6 +147,20 @@ abstract class BaseFeatureQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Feature A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -155,12 +168,12 @@ abstract class BaseFeatureQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Feature A model object, or null if the key is not found - * @throws PropelException + * @return Feature A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `feature` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at` FROM `feature` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -256,7 +269,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -269,8 +283,22 @@ abstract class BaseFeatureQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FeaturePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FeaturePeer::ID, $id, $comparison); @@ -283,7 +311,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -324,7 +353,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -450,8 +480,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * @param FeatureAv|PropelObjectCollection $featureAv the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureAv($featureAv, $comparison = null) { @@ -524,8 +554,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureProd($featureProd, $comparison = null) { @@ -598,8 +628,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureCategory($featureCategory, $comparison = null) { @@ -672,8 +702,8 @@ abstract class BaseFeatureQuery extends ModelCriteria * @param FeatureI18n|PropelObjectCollection $featureI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FeatureQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureI18n($featureI18n, $comparison = null) { @@ -832,7 +862,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @return FeatureQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; @@ -850,7 +880,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @return FeatureQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -871,7 +901,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @return FeatureI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php index 7740b7329..d5881a5f2 100644 --- a/core/lib/Thelia/Model/om/BaseFolder.php +++ b/core/lib/Thelia/Model/om/BaseFolder.php @@ -171,13 +171,19 @@ abstract class BaseFolder extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -319,22 +325,25 @@ abstract class BaseFolder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -356,22 +365,25 @@ abstract class BaseFolder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -403,22 +415,25 @@ abstract class BaseFolder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -439,7 +454,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -460,7 +475,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setParent($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -481,7 +496,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setLink($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -502,7 +517,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -523,7 +538,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -590,7 +605,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -634,7 +649,7 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -700,7 +715,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 10; // 10 = FolderPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -934,7 +949,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collImages !== null) { foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -952,7 +967,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collDocuments !== null) { foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -970,7 +985,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -987,7 +1002,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collContentFolders !== null) { foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1004,7 +1019,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collFolderI18ns !== null) { foreach ($this->collFolderI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1021,7 +1036,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->collFolderVersions !== null) { foreach ($this->collFolderVersions as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1054,34 +1069,34 @@ abstract class BaseFolder extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FolderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FolderPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`PARENT`'; + $modifiedColumns[':p' . $index++] = '`parent`'; } if ($this->isColumnModified(FolderPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`LINK`'; + $modifiedColumns[':p' . $index++] = '`link`'; } if ($this->isColumnModified(FolderPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(FolderPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(FolderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FolderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(FolderPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -1094,34 +1109,34 @@ abstract class BaseFolder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PARENT`': + case '`parent`': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`LINK`': + case '`link`': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1192,11 +1207,11 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1717,13 +1732,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addImages() */ public function clearImages() { $this->collImages = null; // important to set this to null since that means it is uninitialized $this->collImagesPartial = null; + + return $this; } /** @@ -1795,6 +1812,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collImagesPartial = true; } + $collImages->getInternalIterator()->rewind(); return $collImages; } @@ -1822,12 +1840,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $images A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setImages(PropelCollection $images, PropelPDO $con = null) { - $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); + $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - foreach ($this->imagesScheduledForDeletion as $imageRemoved) { + $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setFolder(null); } @@ -1838,6 +1859,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collImages = $images; $this->collImagesPartial = false; + + return $this; } /** @@ -1855,22 +1878,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collImages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collImages) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collImages); + + if($partial && !$criteria) { + return count($this->getImages()); + } + $query = ImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collImages); } /** @@ -1886,7 +1909,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initImages(); $this->collImagesPartial = true; } - if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddImage($l); } @@ -1904,6 +1927,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param Image $image The image object to remove. + * @return Folder The current object (for fluent API support) */ public function removeImage($image) { @@ -1916,6 +1940,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->imagesScheduledForDeletion[]= $image; $image->setFolder(null); } + + return $this; } @@ -1999,13 +2025,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addDocuments() */ public function clearDocuments() { $this->collDocuments = null; // important to set this to null since that means it is uninitialized $this->collDocumentsPartial = null; + + return $this; } /** @@ -2077,6 +2105,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collDocumentsPartial = true; } + $collDocuments->getInternalIterator()->rewind(); return $collDocuments; } @@ -2104,12 +2133,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $documents A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setDocuments(PropelCollection $documents, PropelPDO $con = null) { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setFolder(null); } @@ -2120,6 +2152,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collDocuments = $documents; $this->collDocumentsPartial = false; + + return $this; } /** @@ -2137,22 +2171,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collDocuments || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocuments) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collDocuments); + + if($partial && !$criteria) { + return count($this->getDocuments()); + } + $query = DocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collDocuments); } /** @@ -2168,7 +2202,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initDocuments(); $this->collDocumentsPartial = true; } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDocument($l); } @@ -2186,6 +2220,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param Document $document The document object to remove. + * @return Folder The current object (for fluent API support) */ public function removeDocument($document) { @@ -2198,6 +2233,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->documentsScheduledForDeletion[]= $document; $document->setFolder(null); } + + return $this; } @@ -2281,13 +2318,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addRewritings() */ public function clearRewritings() { $this->collRewritings = null; // important to set this to null since that means it is uninitialized $this->collRewritingsPartial = null; + + return $this; } /** @@ -2359,6 +2398,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collRewritingsPartial = true; } + $collRewritings->getInternalIterator()->rewind(); return $collRewritings; } @@ -2386,12 +2426,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $rewritings A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) { - $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings); + $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) { + $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setFolder(null); } @@ -2402,6 +2445,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collRewritings = $rewritings; $this->collRewritingsPartial = false; + + return $this; } /** @@ -2419,22 +2464,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collRewritings || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRewritings) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collRewritings); + + if($partial && !$criteria) { + return count($this->getRewritings()); + } + $query = RewritingQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collRewritings); } /** @@ -2450,7 +2495,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initRewritings(); $this->collRewritingsPartial = true; } - if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRewriting($l); } @@ -2468,6 +2513,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param Rewriting $rewriting The rewriting object to remove. + * @return Folder The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -2480,6 +2526,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->rewritingsScheduledForDeletion[]= $rewriting; $rewriting->setFolder(null); } + + return $this; } @@ -2563,13 +2611,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addContentFolders() */ public function clearContentFolders() { $this->collContentFolders = null; // important to set this to null since that means it is uninitialized $this->collContentFoldersPartial = null; + + return $this; } /** @@ -2641,6 +2691,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collContentFoldersPartial = true; } + $collContentFolders->getInternalIterator()->rewind(); return $collContentFolders; } @@ -2668,12 +2719,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $contentFolders A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) { - $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); + $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { + $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); + + foreach ($contentFoldersToDelete as $contentFolderRemoved) { $contentFolderRemoved->setFolder(null); } @@ -2684,6 +2738,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collContentFolders = $contentFolders; $this->collContentFoldersPartial = false; + + return $this; } /** @@ -2701,22 +2757,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collContentFolders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentFolders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentFolders()); - } - $query = ContentFolderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collContentFolders); + + if($partial && !$criteria) { + return count($this->getContentFolders()); + } + $query = ContentFolderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collContentFolders); } /** @@ -2732,7 +2788,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initContentFolders(); $this->collContentFoldersPartial = true; } - if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentFolder($l); } @@ -2750,6 +2806,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param ContentFolder $contentFolder The contentFolder object to remove. + * @return Folder The current object (for fluent API support) */ public function removeContentFolder($contentFolder) { @@ -2759,9 +2816,11 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; $this->contentFoldersScheduledForDeletion->clear(); } - $this->contentFoldersScheduledForDeletion[]= $contentFolder; + $this->contentFoldersScheduledForDeletion[]= clone $contentFolder; $contentFolder->setFolder(null); } + + return $this; } @@ -2795,13 +2854,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addFolderI18ns() */ public function clearFolderI18ns() { $this->collFolderI18ns = null; // important to set this to null since that means it is uninitialized $this->collFolderI18nsPartial = null; + + return $this; } /** @@ -2873,6 +2934,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collFolderI18nsPartial = true; } + $collFolderI18ns->getInternalIterator()->rewind(); return $collFolderI18ns; } @@ -2900,12 +2962,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $folderI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setFolderI18ns(PropelCollection $folderI18ns, PropelPDO $con = null) { - $this->folderI18nsScheduledForDeletion = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns); + $folderI18nsToDelete = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns); - foreach ($this->folderI18nsScheduledForDeletion as $folderI18nRemoved) { + $this->folderI18nsScheduledForDeletion = unserialize(serialize($folderI18nsToDelete)); + + foreach ($folderI18nsToDelete as $folderI18nRemoved) { $folderI18nRemoved->setFolder(null); } @@ -2916,6 +2981,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collFolderI18ns = $folderI18ns; $this->collFolderI18nsPartial = false; + + return $this; } /** @@ -2933,22 +3000,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collFolderI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFolderI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFolderI18ns()); - } - $query = FolderI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collFolderI18ns); + + if($partial && !$criteria) { + return count($this->getFolderI18ns()); + } + $query = FolderI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collFolderI18ns); } /** @@ -2968,7 +3035,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initFolderI18ns(); $this->collFolderI18nsPartial = true; } - if (!$this->collFolderI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFolderI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFolderI18n($l); } @@ -2986,6 +3053,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param FolderI18n $folderI18n The folderI18n object to remove. + * @return Folder The current object (for fluent API support) */ public function removeFolderI18n($folderI18n) { @@ -2995,9 +3063,11 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->folderI18nsScheduledForDeletion = clone $this->collFolderI18ns; $this->folderI18nsScheduledForDeletion->clear(); } - $this->folderI18nsScheduledForDeletion[]= $folderI18n; + $this->folderI18nsScheduledForDeletion[]= clone $folderI18n; $folderI18n->setFolder(null); } + + return $this; } /** @@ -3006,13 +3076,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Folder The current object (for fluent API support) * @see addFolderVersions() */ public function clearFolderVersions() { $this->collFolderVersions = null; // important to set this to null since that means it is uninitialized $this->collFolderVersionsPartial = null; + + return $this; } /** @@ -3084,6 +3156,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collFolderVersionsPartial = true; } + $collFolderVersions->getInternalIterator()->rewind(); return $collFolderVersions; } @@ -3111,12 +3184,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param PropelCollection $folderVersions A Propel collection. * @param PropelPDO $con Optional connection object + * @return Folder The current object (for fluent API support) */ public function setFolderVersions(PropelCollection $folderVersions, PropelPDO $con = null) { - $this->folderVersionsScheduledForDeletion = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions); + $folderVersionsToDelete = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions); - foreach ($this->folderVersionsScheduledForDeletion as $folderVersionRemoved) { + $this->folderVersionsScheduledForDeletion = unserialize(serialize($folderVersionsToDelete)); + + foreach ($folderVersionsToDelete as $folderVersionRemoved) { $folderVersionRemoved->setFolder(null); } @@ -3127,6 +3203,8 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collFolderVersions = $folderVersions; $this->collFolderVersionsPartial = false; + + return $this; } /** @@ -3144,22 +3222,22 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null === $this->collFolderVersions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFolderVersions) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFolderVersions()); - } - $query = FolderVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); } - } else { - return count($this->collFolderVersions); + + if($partial && !$criteria) { + return count($this->getFolderVersions()); + } + $query = FolderVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); } + + return count($this->collFolderVersions); } /** @@ -3175,7 +3253,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->initFolderVersions(); $this->collFolderVersionsPartial = true; } - if (!$this->collFolderVersions->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFolderVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFolderVersion($l); } @@ -3193,6 +3271,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * @param FolderVersion $folderVersion The folderVersion object to remove. + * @return Folder The current object (for fluent API support) */ public function removeFolderVersion($folderVersion) { @@ -3202,9 +3281,11 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->folderVersionsScheduledForDeletion = clone $this->collFolderVersions; $this->folderVersionsScheduledForDeletion->clear(); } - $this->folderVersionsScheduledForDeletion[]= $folderVersion; + $this->folderVersionsScheduledForDeletion[]= clone $folderVersion; $folderVersion->setFolder(null); } + + return $this; } /** @@ -3224,6 +3305,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -3242,7 +3324,8 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collImages) { foreach ($this->collImages as $o) { $o->clearAllReferences($deep); @@ -3273,10 +3356,12 @@ abstract class BaseFolder extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collImages instanceof PropelCollection) { @@ -3348,7 +3433,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @return Folder The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -3372,7 +3457,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return FolderI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderI18ns) { @@ -3407,7 +3492,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @return Folder The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { FolderI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseFolderI18n.php b/core/lib/Thelia/Model/om/BaseFolderI18n.php index c55901626..0da44efde 100644 --- a/core/lib/Thelia/Model/om/BaseFolderI18n.php +++ b/core/lib/Thelia/Model/om/BaseFolderI18n.php @@ -53,7 +53,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = FolderI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FolderI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FolderI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(FolderI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(FolderI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(FolderI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(FolderI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->id !== null)) { + if ($this->aFolder === null && ($this->id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseFolderI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aFolder = null; diff --git a/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php b/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php index 713476163..d533de0ce 100644 --- a/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseFolderI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'folder_i18n.ID'; + /** the column name for the id field */ + const ID = 'folder_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'folder_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'folder_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'folder_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'folder_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'folder_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'folder_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'folder_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'folder_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'folder_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'folder_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseFolderI18nPeer $criteria->addSelectColumn(FolderI18nPeer::CHAPO); $criteria->addSelectColumn(FolderI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseFolderI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseFolderI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FolderI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FolderI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseFolderI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FolderI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php b/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php index cbe1734c3..8f2109c60 100644 --- a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * Returns a new FolderI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FolderI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param FolderI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return FolderI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FolderI18n A model object, or null if the key is not found - * @throws PropelException + * @return FolderI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `folder_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `folder_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByFolder() @@ -273,8 +274,22 @@ abstract class BaseFolderI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FolderI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php index 1399a3f3f..66503f818 100644 --- a/core/lib/Thelia/Model/om/BaseFolderPeer.php +++ b/core/lib/Thelia/Model/om/BaseFolderPeer.php @@ -50,35 +50,35 @@ abstract class BaseFolderPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 10; - /** the column name for the ID field */ - const ID = 'folder.ID'; + /** the column name for the id field */ + const ID = 'folder.id'; - /** the column name for the PARENT field */ - const PARENT = 'folder.PARENT'; + /** the column name for the parent field */ + const PARENT = 'folder.parent'; - /** the column name for the LINK field */ - const LINK = 'folder.LINK'; + /** the column name for the link field */ + const LINK = 'folder.link'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'folder.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'folder.visible'; - /** the column name for the POSITION field */ - const POSITION = 'folder.POSITION'; + /** the column name for the position field */ + const POSITION = 'folder.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'folder.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'folder.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'folder.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'folder.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'folder.VERSION'; + /** the column name for the version field */ + const VERSION = 'folder.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'folder.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'folder.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'folder.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'folder.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -98,7 +98,7 @@ abstract class BaseFolderPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; // versionable behavior /** @@ -218,16 +218,16 @@ abstract class BaseFolderPeer $criteria->addSelectColumn(FolderPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(FolderPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.parent'); + $criteria->addSelectColumn($alias . '.link'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -311,7 +311,7 @@ abstract class BaseFolderPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -416,8 +416,15 @@ abstract class BaseFolderPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FolderPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FolderPeer::$instances = array(); } @@ -570,7 +577,7 @@ abstract class BaseFolderPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FolderPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php index 512671886..ed380cd16 100644 --- a/core/lib/Thelia/Model/om/BaseFolderQuery.php +++ b/core/lib/Thelia/Model/om/BaseFolderQuery.php @@ -80,7 +80,6 @@ use Thelia\Model\Rewriting; * @method Folder findOne(PropelPDO $con = null) Return the first Folder matching the query * @method Folder findOneOrCreate(PropelPDO $con = null) Return the first Folder matching the query, or a new Folder object populated from the query conditions when no match is found * - * @method Folder findOneById(int $id) Return the first Folder filtered by the id column * @method Folder findOneByParent(int $parent) Return the first Folder filtered by the parent column * @method Folder findOneByLink(string $link) Return the first Folder filtered by the link column * @method Folder findOneByVisible(int $visible) Return the first Folder filtered by the visible column @@ -122,7 +121,7 @@ abstract class BaseFolderQuery extends ModelCriteria * Returns a new FolderQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FolderQuery|Criteria $criteria Optional Criteria to build the query from + * @param FolderQuery|Criteria $criteria Optional Criteria to build the query from * * @return FolderQuery */ @@ -178,6 +177,20 @@ abstract class BaseFolderQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Folder A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -185,12 +198,12 @@ abstract class BaseFolderQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Folder A model object, or null if the key is not found - * @throws PropelException + * @return Folder A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `folder` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `folder` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -286,7 +299,8 @@ abstract class BaseFolderQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -299,8 +313,22 @@ abstract class BaseFolderQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FolderPeer::ID, $id, $comparison); @@ -313,7 +341,8 @@ abstract class BaseFolderQuery extends ModelCriteria * * $query->filterByParent(1234); // WHERE parent = 1234 * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 + * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 * * * @param mixed $parent The value to use as filter. @@ -383,7 +412,8 @@ abstract class BaseFolderQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -424,7 +454,8 @@ abstract class BaseFolderQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -551,7 +582,8 @@ abstract class BaseFolderQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -663,8 +695,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param Image|PropelObjectCollection $image the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImage($image, $comparison = null) { @@ -737,8 +769,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param Document|PropelObjectCollection $document the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocument($document, $comparison = null) { @@ -811,8 +843,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByRewriting($rewriting, $comparison = null) { @@ -885,8 +917,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentFolder($contentFolder, $comparison = null) { @@ -959,8 +991,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param FolderI18n|PropelObjectCollection $folderI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolderI18n($folderI18n, $comparison = null) { @@ -1033,8 +1065,8 @@ abstract class BaseFolderQuery extends ModelCriteria * @param FolderVersion|PropelObjectCollection $folderVersion the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolderVersion($folderVersion, $comparison = null) { @@ -1193,7 +1225,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * @return FolderQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; @@ -1211,7 +1243,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * @return FolderQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1232,7 +1264,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * @return FolderI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseFolderVersion.php b/core/lib/Thelia/Model/om/BaseFolderVersion.php index e9ed39e36..c83e6a410 100644 --- a/core/lib/Thelia/Model/om/BaseFolderVersion.php +++ b/core/lib/Thelia/Model/om/BaseFolderVersion.php @@ -127,6 +127,12 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -217,22 +223,25 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -254,22 +263,25 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -301,22 +313,25 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -337,7 +352,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -362,7 +377,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setParent($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -383,7 +398,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setLink($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -404,7 +419,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -425,7 +440,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -492,7 +507,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -536,7 +551,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -602,7 +617,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 10; // 10 = FolderVersionPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -828,34 +843,34 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(FolderVersionPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(FolderVersionPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`PARENT`'; + $modifiedColumns[':p' . $index++] = '`parent`'; } if ($this->isColumnModified(FolderVersionPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`LINK`'; + $modifiedColumns[':p' . $index++] = '`link`'; } if ($this->isColumnModified(FolderVersionPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(FolderVersionPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(FolderVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(FolderVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(FolderVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(FolderVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -868,34 +883,34 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PARENT`': + case '`parent`': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`LINK`': + case '`link`': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -959,11 +974,11 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1399,12 +1414,13 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->id !== null)) { + if ($this->aFolder === null && ($this->id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1435,6 +1451,7 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1453,7 +1470,13 @@ abstract class BaseFolderVersion extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aFolder = null; diff --git a/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php b/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php index 4b61116cd..45c3292e3 100644 --- a/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php +++ b/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php @@ -45,35 +45,35 @@ abstract class BaseFolderVersionPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 10; - /** the column name for the ID field */ - const ID = 'folder_version.ID'; + /** the column name for the id field */ + const ID = 'folder_version.id'; - /** the column name for the PARENT field */ - const PARENT = 'folder_version.PARENT'; + /** the column name for the parent field */ + const PARENT = 'folder_version.parent'; - /** the column name for the LINK field */ - const LINK = 'folder_version.LINK'; + /** the column name for the link field */ + const LINK = 'folder_version.link'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'folder_version.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'folder_version.visible'; - /** the column name for the POSITION field */ - const POSITION = 'folder_version.POSITION'; + /** the column name for the position field */ + const POSITION = 'folder_version.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'folder_version.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'folder_version.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'folder_version.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'folder_version.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'folder_version.VERSION'; + /** the column name for the version field */ + const VERSION = 'folder_version.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'folder_version.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'folder_version.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'folder_version.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'folder_version.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -199,16 +199,16 @@ abstract class BaseFolderVersionPeer $criteria->addSelectColumn(FolderVersionPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(FolderVersionPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.parent'); + $criteria->addSelectColumn($alias . '.link'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -292,7 +292,7 @@ abstract class BaseFolderVersionPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -397,8 +397,15 @@ abstract class BaseFolderVersionPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (FolderVersionPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } FolderVersionPeer::$instances = array(); } @@ -771,7 +778,7 @@ abstract class BaseFolderVersionPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return FolderVersionPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php b/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php index 44e12b519..1c16728b4 100644 --- a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php +++ b/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php @@ -97,7 +97,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * Returns a new FolderVersionQuery object. * * @param string $modelAlias The alias of a model in the query - * @param FolderVersionQuery|Criteria $criteria Optional Criteria to build the query from + * @param FolderVersionQuery|Criteria $criteria Optional Criteria to build the query from * * @return FolderVersionQuery */ @@ -161,12 +161,12 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return FolderVersion A model object, or null if the key is not found - * @throws PropelException + * @return FolderVersion A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PARENT`, `LINK`, `VISIBLE`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `folder_version` WHERE `ID` = :p0 AND `VERSION` = :p1'; + $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `folder_version` WHERE `id` = :p0 AND `version` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -274,7 +274,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByFolder() @@ -289,8 +290,22 @@ abstract class BaseFolderVersionQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FolderVersionPeer::ID, $id, $comparison); @@ -303,7 +318,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $query->filterByParent(1234); // WHERE parent = 1234 * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 + * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 * * * @param mixed $parent The value to use as filter. @@ -373,7 +389,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -414,7 +431,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -541,7 +559,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -554,8 +573,22 @@ abstract class BaseFolderVersionQuery extends ModelCriteria */ public function filterByVersion($version = null, $comparison = null) { - if (is_array($version) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(FolderVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(FolderVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(FolderVersionPeer::VERSION, $version, $comparison); @@ -639,8 +672,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return FolderVersionQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return FolderVersionQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseGroup.php b/core/lib/Thelia/Model/om/BaseGroup.php index 785698a99..a8a53dba7 100644 --- a/core/lib/Thelia/Model/om/BaseGroup.php +++ b/core/lib/Thelia/Model/om/BaseGroup.php @@ -117,13 +117,19 @@ abstract class BaseGroup extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -194,22 +200,25 @@ abstract class BaseGroup extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -231,22 +240,25 @@ abstract class BaseGroup extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -257,7 +269,7 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -278,7 +290,7 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -380,7 +392,7 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = GroupPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -598,7 +610,7 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->collAdminGroups !== null) { foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -615,7 +627,7 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->collGroupResources !== null) { foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -632,7 +644,7 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->collGroupModules !== null) { foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -649,7 +661,7 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->collGroupI18ns !== null) { foreach ($this->collGroupI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -682,16 +694,16 @@ abstract class BaseGroup extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(GroupPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(GroupPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(GroupPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(GroupPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -704,16 +716,16 @@ abstract class BaseGroup extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -784,11 +796,11 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1209,13 +1221,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Group The current object (for fluent API support) * @see addAdminGroups() */ public function clearAdminGroups() { $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized $this->collAdminGroupsPartial = null; + + return $this; } /** @@ -1287,6 +1301,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collAdminGroupsPartial = true; } + $collAdminGroups->getInternalIterator()->rewind(); return $collAdminGroups; } @@ -1314,12 +1329,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param PropelCollection $adminGroups A Propel collection. * @param PropelPDO $con Optional connection object + * @return Group The current object (for fluent API support) */ public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) { - $this->adminGroupsScheduledForDeletion = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); + $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - foreach ($this->adminGroupsScheduledForDeletion as $adminGroupRemoved) { + $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); + + foreach ($adminGroupsToDelete as $adminGroupRemoved) { $adminGroupRemoved->setGroup(null); } @@ -1330,6 +1348,8 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collAdminGroups = $adminGroups; $this->collAdminGroupsPartial = false; + + return $this; } /** @@ -1347,22 +1367,22 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null === $this->collAdminGroups || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAdminGroups) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAdminGroups()); - } - $query = AdminGroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); } - } else { - return count($this->collAdminGroups); + + if($partial && !$criteria) { + return count($this->getAdminGroups()); + } + $query = AdminGroupQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByGroup($this) + ->count($con); } + + return count($this->collAdminGroups); } /** @@ -1378,7 +1398,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->initAdminGroups(); $this->collAdminGroupsPartial = true; } - if (!$this->collAdminGroups->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAdminGroup($l); } @@ -1396,6 +1416,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * @param AdminGroup $adminGroup The adminGroup object to remove. + * @return Group The current object (for fluent API support) */ public function removeAdminGroup($adminGroup) { @@ -1408,6 +1429,8 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->adminGroupsScheduledForDeletion[]= $adminGroup; $adminGroup->setGroup(null); } + + return $this; } @@ -1441,13 +1464,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Group The current object (for fluent API support) * @see addGroupResources() */ public function clearGroupResources() { $this->collGroupResources = null; // important to set this to null since that means it is uninitialized $this->collGroupResourcesPartial = null; + + return $this; } /** @@ -1519,6 +1544,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupResourcesPartial = true; } + $collGroupResources->getInternalIterator()->rewind(); return $collGroupResources; } @@ -1546,12 +1572,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param PropelCollection $groupResources A Propel collection. * @param PropelPDO $con Optional connection object + * @return Group The current object (for fluent API support) */ public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) { - $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); + $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) { + $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); + + foreach ($groupResourcesToDelete as $groupResourceRemoved) { $groupResourceRemoved->setGroup(null); } @@ -1562,6 +1591,8 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupResources = $groupResources; $this->collGroupResourcesPartial = false; + + return $this; } /** @@ -1579,22 +1610,22 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null === $this->collGroupResources || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupResources) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getGroupResources()); - } - $query = GroupResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); } - } else { - return count($this->collGroupResources); + + if($partial && !$criteria) { + return count($this->getGroupResources()); + } + $query = GroupResourceQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByGroup($this) + ->count($con); } + + return count($this->collGroupResources); } /** @@ -1610,7 +1641,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->initGroupResources(); $this->collGroupResourcesPartial = true; } - if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddGroupResource($l); } @@ -1628,6 +1659,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * @param GroupResource $groupResource The groupResource object to remove. + * @return Group The current object (for fluent API support) */ public function removeGroupResource($groupResource) { @@ -1637,9 +1669,11 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; $this->groupResourcesScheduledForDeletion->clear(); } - $this->groupResourcesScheduledForDeletion[]= $groupResource; + $this->groupResourcesScheduledForDeletion[]= clone $groupResource; $groupResource->setGroup(null); } + + return $this; } @@ -1673,13 +1707,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Group The current object (for fluent API support) * @see addGroupModules() */ public function clearGroupModules() { $this->collGroupModules = null; // important to set this to null since that means it is uninitialized $this->collGroupModulesPartial = null; + + return $this; } /** @@ -1751,6 +1787,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupModulesPartial = true; } + $collGroupModules->getInternalIterator()->rewind(); return $collGroupModules; } @@ -1778,12 +1815,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param PropelCollection $groupModules A Propel collection. * @param PropelPDO $con Optional connection object + * @return Group The current object (for fluent API support) */ public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) { - $this->groupModulesScheduledForDeletion = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); + $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - foreach ($this->groupModulesScheduledForDeletion as $groupModuleRemoved) { + $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); + + foreach ($groupModulesToDelete as $groupModuleRemoved) { $groupModuleRemoved->setGroup(null); } @@ -1794,6 +1834,8 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupModules = $groupModules; $this->collGroupModulesPartial = false; + + return $this; } /** @@ -1811,22 +1853,22 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null === $this->collGroupModules || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupModules) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getGroupModules()); - } - $query = GroupModuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); } - } else { - return count($this->collGroupModules); + + if($partial && !$criteria) { + return count($this->getGroupModules()); + } + $query = GroupModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByGroup($this) + ->count($con); } + + return count($this->collGroupModules); } /** @@ -1842,7 +1884,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->initGroupModules(); $this->collGroupModulesPartial = true; } - if (!$this->collGroupModules->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddGroupModule($l); } @@ -1860,6 +1902,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * @param GroupModule $groupModule The groupModule object to remove. + * @return Group The current object (for fluent API support) */ public function removeGroupModule($groupModule) { @@ -1869,9 +1912,11 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->groupModulesScheduledForDeletion = clone $this->collGroupModules; $this->groupModulesScheduledForDeletion->clear(); } - $this->groupModulesScheduledForDeletion[]= $groupModule; + $this->groupModulesScheduledForDeletion[]= clone $groupModule; $groupModule->setGroup(null); } + + return $this; } @@ -1905,13 +1950,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Group The current object (for fluent API support) * @see addGroupI18ns() */ public function clearGroupI18ns() { $this->collGroupI18ns = null; // important to set this to null since that means it is uninitialized $this->collGroupI18nsPartial = null; + + return $this; } /** @@ -1983,6 +2030,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupI18nsPartial = true; } + $collGroupI18ns->getInternalIterator()->rewind(); return $collGroupI18ns; } @@ -2010,12 +2058,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param PropelCollection $groupI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Group The current object (for fluent API support) */ public function setGroupI18ns(PropelCollection $groupI18ns, PropelPDO $con = null) { - $this->groupI18nsScheduledForDeletion = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns); + $groupI18nsToDelete = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns); - foreach ($this->groupI18nsScheduledForDeletion as $groupI18nRemoved) { + $this->groupI18nsScheduledForDeletion = unserialize(serialize($groupI18nsToDelete)); + + foreach ($groupI18nsToDelete as $groupI18nRemoved) { $groupI18nRemoved->setGroup(null); } @@ -2026,6 +2077,8 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->collGroupI18ns = $groupI18ns; $this->collGroupI18nsPartial = false; + + return $this; } /** @@ -2043,22 +2096,22 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null === $this->collGroupI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getGroupI18ns()); - } - $query = GroupI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); } - } else { - return count($this->collGroupI18ns); + + if($partial && !$criteria) { + return count($this->getGroupI18ns()); + } + $query = GroupI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByGroup($this) + ->count($con); } + + return count($this->collGroupI18ns); } /** @@ -2078,7 +2131,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->initGroupI18ns(); $this->collGroupI18nsPartial = true; } - if (!$this->collGroupI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddGroupI18n($l); } @@ -2096,6 +2149,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * @param GroupI18n $groupI18n The groupI18n object to remove. + * @return Group The current object (for fluent API support) */ public function removeGroupI18n($groupI18n) { @@ -2105,9 +2159,11 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->groupI18nsScheduledForDeletion = clone $this->collGroupI18ns; $this->groupI18nsScheduledForDeletion->clear(); } - $this->groupI18nsScheduledForDeletion[]= $groupI18n; + $this->groupI18nsScheduledForDeletion[]= clone $groupI18n; $groupI18n->setGroup(null); } + + return $this; } /** @@ -2121,6 +2177,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2138,7 +2195,8 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collAdminGroups) { foreach ($this->collAdminGroups as $o) { $o->clearAllReferences($deep); @@ -2159,10 +2217,12 @@ abstract class BaseGroup extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAdminGroups instanceof PropelCollection) { @@ -2226,7 +2286,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @return Group The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2250,7 +2310,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return GroupI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collGroupI18ns) { @@ -2285,7 +2345,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @return Group The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { GroupI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseGroupI18n.php b/core/lib/Thelia/Model/om/BaseGroupI18n.php index 89ddead03..0aa9c78b0 100644 --- a/core/lib/Thelia/Model/om/BaseGroupI18n.php +++ b/core/lib/Thelia/Model/om/BaseGroupI18n.php @@ -53,7 +53,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = GroupI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(GroupI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(GroupI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(GroupI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(GroupI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(GroupI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(GroupI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent * Get the associated Group object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Group The associated Group object. * @throws PropelException */ - public function getGroup(PropelPDO $con = null) + public function getGroup(PropelPDO $con = null, $doQuery = true) { - if ($this->aGroup === null && ($this->id !== null)) { + if ($this->aGroup === null && ($this->id !== null) && $doQuery) { $this->aGroup = GroupQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseGroupI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aGroup instanceof Persistent) { + $this->aGroup->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aGroup = null; diff --git a/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php b/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php index a76dfab52..56f5b8702 100644 --- a/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseGroupI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'group_i18n.ID'; + /** the column name for the id field */ + const ID = 'group_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'group_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'group_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'group_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'group_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'group_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'group_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'group_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'group_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'group_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'group_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseGroupI18nPeer $criteria->addSelectColumn(GroupI18nPeer::CHAPO); $criteria->addSelectColumn(GroupI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseGroupI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseGroupI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (GroupI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } GroupI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseGroupI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return GroupI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php b/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php index 9abd503d6..f0d73813b 100644 --- a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * Returns a new GroupI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param GroupI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param GroupI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return GroupI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return GroupI18n A model object, or null if the key is not found - * @throws PropelException + * @return GroupI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `group_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `group_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByGroup() @@ -273,8 +274,22 @@ abstract class BaseGroupI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(GroupI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(GroupI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(GroupI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * @param Group|PropelObjectCollection $group The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroup($group, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseGroupModule.php b/core/lib/Thelia/Model/om/BaseGroupModule.php index 5325dc01b..747f025a2 100644 --- a/core/lib/Thelia/Model/om/BaseGroupModule.php +++ b/core/lib/Thelia/Model/om/BaseGroupModule.php @@ -110,6 +110,12 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -190,22 +196,25 @@ abstract class BaseGroupModule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -227,22 +236,25 @@ abstract class BaseGroupModule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -253,7 +265,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -274,7 +286,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ public function setGroupId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -299,7 +311,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ public function setModuleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -324,7 +336,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ public function setAccess($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -432,7 +444,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = GroupModulePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -684,22 +696,22 @@ abstract class BaseGroupModule extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(GroupModulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(GroupModulePeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`GROUP_ID`'; + $modifiedColumns[':p' . $index++] = '`group_id`'; } if ($this->isColumnModified(GroupModulePeer::MODULE_ID)) { - $modifiedColumns[':p' . $index++] = '`MODULE_ID`'; + $modifiedColumns[':p' . $index++] = '`module_id`'; } if ($this->isColumnModified(GroupModulePeer::ACCESS)) { - $modifiedColumns[':p' . $index++] = '`ACCESS`'; + $modifiedColumns[':p' . $index++] = '`access`'; } if ($this->isColumnModified(GroupModulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(GroupModulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -712,22 +724,22 @@ abstract class BaseGroupModule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`GROUP_ID`': + case '`group_id`': $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); break; - case '`MODULE_ID`': + case '`module_id`': $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT); break; - case '`ACCESS`': + case '`access`': $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -798,11 +810,11 @@ abstract class BaseGroupModule extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1200,12 +1212,13 @@ abstract class BaseGroupModule extends BaseObject implements Persistent * Get the associated Group object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Group The associated Group object. * @throws PropelException */ - public function getGroup(PropelPDO $con = null) + public function getGroup(PropelPDO $con = null, $doQuery = true) { - if ($this->aGroup === null && ($this->group_id !== null)) { + if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1251,12 +1264,13 @@ abstract class BaseGroupModule extends BaseObject implements Persistent * Get the associated Module object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Module The associated Module object. * @throws PropelException */ - public function getModule(PropelPDO $con = null) + public function getModule(PropelPDO $con = null, $doQuery = true) { - if ($this->aModule === null && ($this->module_id !== null)) { + if ($this->aModule === null && ($this->module_id !== null) && $doQuery) { $this->aModule = ModuleQuery::create()->findPk($this->module_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1283,6 +1297,7 @@ abstract class BaseGroupModule extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1301,7 +1316,16 @@ abstract class BaseGroupModule extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aGroup instanceof Persistent) { + $this->aGroup->clearAllReferences($deep); + } + if ($this->aModule instanceof Persistent) { + $this->aModule->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aGroup = null; diff --git a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php index 4b01ddc66..629d3bf83 100644 --- a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php +++ b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php @@ -46,23 +46,23 @@ abstract class BaseGroupModulePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'group_module.ID'; + /** the column name for the id field */ + const ID = 'group_module.id'; - /** the column name for the GROUP_ID field */ - const GROUP_ID = 'group_module.GROUP_ID'; + /** the column name for the group_id field */ + const GROUP_ID = 'group_module.group_id'; - /** the column name for the MODULE_ID field */ - const MODULE_ID = 'group_module.MODULE_ID'; + /** the column name for the module_id field */ + const MODULE_ID = 'group_module.module_id'; - /** the column name for the ACCESS field */ - const ACCESS = 'group_module.ACCESS'; + /** the column name for the access field */ + const ACCESS = 'group_module.access'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'group_module.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'group_module.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'group_module.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'group_module.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -184,12 +184,12 @@ abstract class BaseGroupModulePeer $criteria->addSelectColumn(GroupModulePeer::CREATED_AT); $criteria->addSelectColumn(GroupModulePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.MODULE_ID'); - $criteria->addSelectColumn($alias . '.ACCESS'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.group_id'); + $criteria->addSelectColumn($alias . '.module_id'); + $criteria->addSelectColumn($alias . '.access'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -273,7 +273,7 @@ abstract class BaseGroupModulePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -378,8 +378,15 @@ abstract class BaseGroupModulePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (GroupModulePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } GroupModulePeer::$instances = array(); } @@ -1145,7 +1152,7 @@ abstract class BaseGroupModulePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return GroupModulePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php index 3d668f6d0..4a0b7b0d1 100644 --- a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php @@ -52,7 +52,6 @@ use Thelia\Model\Module; * @method GroupModule findOne(PropelPDO $con = null) Return the first GroupModule matching the query * @method GroupModule findOneOrCreate(PropelPDO $con = null) Return the first GroupModule matching the query, or a new GroupModule object populated from the query conditions when no match is found * - * @method GroupModule findOneById(int $id) Return the first GroupModule filtered by the id column * @method GroupModule findOneByGroupId(int $group_id) Return the first GroupModule filtered by the group_id column * @method GroupModule findOneByModuleId(int $module_id) Return the first GroupModule filtered by the module_id column * @method GroupModule findOneByAccess(int $access) Return the first GroupModule filtered by the access column @@ -86,7 +85,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * Returns a new GroupModuleQuery object. * * @param string $modelAlias The alias of a model in the query - * @param GroupModuleQuery|Criteria $criteria Optional Criteria to build the query from + * @param GroupModuleQuery|Criteria $criteria Optional Criteria to build the query from * * @return GroupModuleQuery */ @@ -142,6 +141,20 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return GroupModule A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -149,12 +162,12 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return GroupModule A model object, or null if the key is not found - * @throws PropelException + * @return GroupModule A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `GROUP_ID`, `MODULE_ID`, `ACCESS`, `CREATED_AT`, `UPDATED_AT` FROM `group_module` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `group_id`, `module_id`, `access`, `created_at`, `updated_at` FROM `group_module` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -250,7 +263,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -263,8 +277,22 @@ abstract class BaseGroupModuleQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(GroupModulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(GroupModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(GroupModulePeer::ID, $id, $comparison); @@ -277,7 +305,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $query->filterByGroupId(1234); // WHERE group_id = 1234 * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 + * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 * * * @see filterByGroup() @@ -320,7 +349,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $query->filterByModuleId(1234); // WHERE module_id = 1234 * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34) - * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12 + * $query->filterByModuleId(array('min' => 12)); // WHERE module_id >= 12 + * $query->filterByModuleId(array('max' => 12)); // WHERE module_id <= 12 * * * @see filterByModule() @@ -363,7 +393,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $query->filterByAccess(1234); // WHERE access = 1234 * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) - * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 + * $query->filterByAccess(array('min' => 12)); // WHERE access >= 12 + * $query->filterByAccess(array('max' => 12)); // WHERE access <= 12 * * * @param mixed $access The value to use as filter. @@ -489,8 +520,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * @param Group|PropelObjectCollection $group The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupModuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroup($group, $comparison = null) { @@ -565,8 +596,8 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * @param Module|PropelObjectCollection $module The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupModuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByModule($module, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseGroupPeer.php b/core/lib/Thelia/Model/om/BaseGroupPeer.php index 557528ce6..1a1a18f1e 100644 --- a/core/lib/Thelia/Model/om/BaseGroupPeer.php +++ b/core/lib/Thelia/Model/om/BaseGroupPeer.php @@ -48,17 +48,17 @@ abstract class BaseGroupPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'group.ID'; + /** the column name for the id field */ + const ID = 'group.id'; - /** the column name for the CODE field */ - const CODE = 'group.CODE'; + /** the column name for the code field */ + const CODE = 'group.code'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'group.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'group.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'group.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'group.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -78,7 +78,7 @@ abstract class BaseGroupPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -185,10 +185,10 @@ abstract class BaseGroupPeer $criteria->addSelectColumn(GroupPeer::CREATED_AT); $criteria->addSelectColumn(GroupPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -272,7 +272,7 @@ abstract class BaseGroupPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseGroupPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (GroupPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } GroupPeer::$instances = array(); } @@ -525,7 +532,7 @@ abstract class BaseGroupPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return GroupPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/om/BaseGroupQuery.php index 9806ff053..d868338df 100644 --- a/core/lib/Thelia/Model/om/BaseGroupQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupQuery.php @@ -58,7 +58,6 @@ use Thelia\Model\GroupResource; * @method Group findOne(PropelPDO $con = null) Return the first Group matching the query * @method Group findOneOrCreate(PropelPDO $con = null) Return the first Group matching the query, or a new Group object populated from the query conditions when no match is found * - * @method Group findOneById(int $id) Return the first Group filtered by the id column * @method Group findOneByCode(string $code) Return the first Group filtered by the code column * @method Group findOneByCreatedAt(string $created_at) Return the first Group filtered by the created_at column * @method Group findOneByUpdatedAt(string $updated_at) Return the first Group filtered by the updated_at column @@ -88,7 +87,7 @@ abstract class BaseGroupQuery extends ModelCriteria * Returns a new GroupQuery object. * * @param string $modelAlias The alias of a model in the query - * @param GroupQuery|Criteria $criteria Optional Criteria to build the query from + * @param GroupQuery|Criteria $criteria Optional Criteria to build the query from * * @return GroupQuery */ @@ -144,6 +143,20 @@ abstract class BaseGroupQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Group A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -151,12 +164,12 @@ abstract class BaseGroupQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Group A model object, or null if the key is not found - * @throws PropelException + * @return Group A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `group` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `group` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -252,7 +265,8 @@ abstract class BaseGroupQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -265,8 +279,22 @@ abstract class BaseGroupQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(GroupPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(GroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(GroupPeer::ID, $id, $comparison); @@ -393,8 +421,8 @@ abstract class BaseGroupQuery extends ModelCriteria * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAdminGroup($adminGroup, $comparison = null) { @@ -467,8 +495,8 @@ abstract class BaseGroupQuery extends ModelCriteria * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroupResource($groupResource, $comparison = null) { @@ -541,8 +569,8 @@ abstract class BaseGroupQuery extends ModelCriteria * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroupModule($groupModule, $comparison = null) { @@ -615,8 +643,8 @@ abstract class BaseGroupQuery extends ModelCriteria * @param GroupI18n|PropelObjectCollection $groupI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroupI18n($groupI18n, $comparison = null) { @@ -775,7 +803,7 @@ abstract class BaseGroupQuery extends ModelCriteria * * @return GroupQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; @@ -793,7 +821,7 @@ abstract class BaseGroupQuery extends ModelCriteria * * @return GroupQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -814,7 +842,7 @@ abstract class BaseGroupQuery extends ModelCriteria * * @return GroupI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseGroupResource.php b/core/lib/Thelia/Model/om/BaseGroupResource.php index 8dc1b3f46..055228992 100644 --- a/core/lib/Thelia/Model/om/BaseGroupResource.php +++ b/core/lib/Thelia/Model/om/BaseGroupResource.php @@ -117,6 +117,12 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -208,22 +214,25 @@ abstract class BaseGroupResource extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -245,22 +254,25 @@ abstract class BaseGroupResource extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -271,7 +283,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -292,7 +304,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function setGroupId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -317,7 +329,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function setResourceId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -342,7 +354,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function setRead($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -363,7 +375,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function setWrite($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -476,7 +488,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = GroupResourcePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -728,25 +740,25 @@ abstract class BaseGroupResource extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(GroupResourcePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(GroupResourcePeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`GROUP_ID`'; + $modifiedColumns[':p' . $index++] = '`group_id`'; } if ($this->isColumnModified(GroupResourcePeer::RESOURCE_ID)) { - $modifiedColumns[':p' . $index++] = '`RESOURCE_ID`'; + $modifiedColumns[':p' . $index++] = '`resource_id`'; } if ($this->isColumnModified(GroupResourcePeer::READ)) { - $modifiedColumns[':p' . $index++] = '`READ`'; + $modifiedColumns[':p' . $index++] = '`read`'; } if ($this->isColumnModified(GroupResourcePeer::WRITE)) { - $modifiedColumns[':p' . $index++] = '`WRITE`'; + $modifiedColumns[':p' . $index++] = '`write`'; } if ($this->isColumnModified(GroupResourcePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -759,25 +771,25 @@ abstract class BaseGroupResource extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`GROUP_ID`': + case '`group_id`': $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); break; - case '`RESOURCE_ID`': + case '`resource_id`': $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); break; - case '`READ`': + case '`read`': $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); break; - case '`WRITE`': + case '`write`': $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -848,11 +860,11 @@ abstract class BaseGroupResource extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1260,12 +1272,13 @@ abstract class BaseGroupResource extends BaseObject implements Persistent * Get the associated Group object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Group The associated Group object. * @throws PropelException */ - public function getGroup(PropelPDO $con = null) + public function getGroup(PropelPDO $con = null, $doQuery = true) { - if ($this->aGroup === null && ($this->group_id !== null)) { + if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1311,12 +1324,13 @@ abstract class BaseGroupResource extends BaseObject implements Persistent * Get the associated Resource object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Resource The associated Resource object. * @throws PropelException */ - public function getResource(PropelPDO $con = null) + public function getResource(PropelPDO $con = null, $doQuery = true) { - if ($this->aResource === null && ($this->resource_id !== null)) { + if ($this->aResource === null && ($this->resource_id !== null) && $doQuery) { $this->aResource = ResourceQuery::create()->findPk($this->resource_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1344,6 +1358,7 @@ abstract class BaseGroupResource extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1362,7 +1377,16 @@ abstract class BaseGroupResource extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aGroup instanceof Persistent) { + $this->aGroup->clearAllReferences($deep); + } + if ($this->aResource instanceof Persistent) { + $this->aResource->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aGroup = null; diff --git a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php index bfecc6147..5ebff6eb1 100644 --- a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php +++ b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php @@ -46,26 +46,26 @@ abstract class BaseGroupResourcePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'group_resource.ID'; + /** the column name for the id field */ + const ID = 'group_resource.id'; - /** the column name for the GROUP_ID field */ - const GROUP_ID = 'group_resource.GROUP_ID'; + /** the column name for the group_id field */ + const GROUP_ID = 'group_resource.group_id'; - /** the column name for the RESOURCE_ID field */ - const RESOURCE_ID = 'group_resource.RESOURCE_ID'; + /** the column name for the resource_id field */ + const RESOURCE_ID = 'group_resource.resource_id'; - /** the column name for the READ field */ - const READ = 'group_resource.READ'; + /** the column name for the read field */ + const READ = 'group_resource.read'; - /** the column name for the WRITE field */ - const WRITE = 'group_resource.WRITE'; + /** the column name for the write field */ + const WRITE = 'group_resource.write'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'group_resource.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'group_resource.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'group_resource.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'group_resource.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -188,13 +188,13 @@ abstract class BaseGroupResourcePeer $criteria->addSelectColumn(GroupResourcePeer::CREATED_AT); $criteria->addSelectColumn(GroupResourcePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.RESOURCE_ID'); - $criteria->addSelectColumn($alias . '.READ'); - $criteria->addSelectColumn($alias . '.WRITE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.group_id'); + $criteria->addSelectColumn($alias . '.resource_id'); + $criteria->addSelectColumn($alias . '.read'); + $criteria->addSelectColumn($alias . '.write'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -278,7 +278,7 @@ abstract class BaseGroupResourcePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -383,8 +383,15 @@ abstract class BaseGroupResourcePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (GroupResourcePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } GroupResourcePeer::$instances = array(); } @@ -1150,7 +1157,7 @@ abstract class BaseGroupResourcePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return GroupResourcePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php index 8c615c227..d203d3bf0 100644 --- a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php @@ -54,7 +54,6 @@ use Thelia\Model\Resource; * @method GroupResource findOne(PropelPDO $con = null) Return the first GroupResource matching the query * @method GroupResource findOneOrCreate(PropelPDO $con = null) Return the first GroupResource matching the query, or a new GroupResource object populated from the query conditions when no match is found * - * @method GroupResource findOneById(int $id) Return the first GroupResource filtered by the id column * @method GroupResource findOneByGroupId(int $group_id) Return the first GroupResource filtered by the group_id column * @method GroupResource findOneByResourceId(int $resource_id) Return the first GroupResource filtered by the resource_id column * @method GroupResource findOneByRead(int $read) Return the first GroupResource filtered by the read column @@ -90,7 +89,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * Returns a new GroupResourceQuery object. * * @param string $modelAlias The alias of a model in the query - * @param GroupResourceQuery|Criteria $criteria Optional Criteria to build the query from + * @param GroupResourceQuery|Criteria $criteria Optional Criteria to build the query from * * @return GroupResourceQuery */ @@ -146,6 +145,20 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return GroupResource A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -153,12 +166,12 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return GroupResource A model object, or null if the key is not found - * @throws PropelException + * @return GroupResource A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `GROUP_ID`, `RESOURCE_ID`, `READ`, `WRITE`, `CREATED_AT`, `UPDATED_AT` FROM `group_resource` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `group_id`, `resource_id`, `read`, `write`, `created_at`, `updated_at` FROM `group_resource` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -254,7 +267,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -267,8 +281,22 @@ abstract class BaseGroupResourceQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(GroupResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(GroupResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(GroupResourcePeer::ID, $id, $comparison); @@ -281,7 +309,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $query->filterByGroupId(1234); // WHERE group_id = 1234 * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 + * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 * * * @see filterByGroup() @@ -324,7 +353,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $query->filterByResourceId(1234); // WHERE resource_id = 1234 * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34) - * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12 + * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id >= 12 + * $query->filterByResourceId(array('max' => 12)); // WHERE resource_id <= 12 * * * @see filterByResource() @@ -367,7 +397,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $query->filterByRead(1234); // WHERE read = 1234 * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) - * $query->filterByRead(array('min' => 12)); // WHERE read > 12 + * $query->filterByRead(array('min' => 12)); // WHERE read >= 12 + * $query->filterByRead(array('max' => 12)); // WHERE read <= 12 * * * @param mixed $read The value to use as filter. @@ -408,7 +439,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $query->filterByWrite(1234); // WHERE write = 1234 * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) - * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 + * $query->filterByWrite(array('min' => 12)); // WHERE write >= 12 + * $query->filterByWrite(array('max' => 12)); // WHERE write <= 12 * * * @param mixed $write The value to use as filter. @@ -534,8 +566,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * @param Group|PropelObjectCollection $group The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupResourceQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroup($group, $comparison = null) { @@ -610,8 +642,8 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return GroupResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return GroupResourceQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByResource($resource, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/om/BaseImage.php index f86d68573..8443cb379 100644 --- a/core/lib/Thelia/Model/om/BaseImage.php +++ b/core/lib/Thelia/Model/om/BaseImage.php @@ -151,13 +151,19 @@ abstract class BaseImage extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -260,22 +266,25 @@ abstract class BaseImage extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -297,22 +306,25 @@ abstract class BaseImage extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -323,7 +335,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -344,7 +356,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -369,7 +381,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -394,7 +406,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setFolderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -419,7 +431,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setContentId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -444,7 +456,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setFile($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -465,7 +477,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -572,7 +584,7 @@ abstract class BaseImage extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 9; // 9 = ImagePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -832,7 +844,7 @@ abstract class BaseImage extends BaseObject implements Persistent if ($this->collImageI18ns !== null) { foreach ($this->collImageI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -865,31 +877,31 @@ abstract class BaseImage extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ImagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(ImagePeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`FOLDER_ID`'; + $modifiedColumns[':p' . $index++] = '`folder_id`'; } if ($this->isColumnModified(ImagePeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`CONTENT_ID`'; + $modifiedColumns[':p' . $index++] = '`content_id`'; } if ($this->isColumnModified(ImagePeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`FILE`'; + $modifiedColumns[':p' . $index++] = '`file`'; } if ($this->isColumnModified(ImagePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ImagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ImagePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -902,31 +914,31 @@ abstract class BaseImage extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`FOLDER_ID`': + case '`folder_id`': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`CONTENT_ID`': + case '`content_id`': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`FILE`': + case '`file`': $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -997,11 +1009,11 @@ abstract class BaseImage extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1464,12 +1476,13 @@ abstract class BaseImage extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1515,12 +1528,13 @@ abstract class BaseImage extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1566,12 +1580,13 @@ abstract class BaseImage extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->content_id !== null)) { + if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1617,12 +1632,13 @@ abstract class BaseImage extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->folder_id !== null)) { + if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1658,13 +1674,15 @@ abstract class BaseImage extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Image The current object (for fluent API support) * @see addImageI18ns() */ public function clearImageI18ns() { $this->collImageI18ns = null; // important to set this to null since that means it is uninitialized $this->collImageI18nsPartial = null; + + return $this; } /** @@ -1736,6 +1754,7 @@ abstract class BaseImage extends BaseObject implements Persistent $this->collImageI18nsPartial = true; } + $collImageI18ns->getInternalIterator()->rewind(); return $collImageI18ns; } @@ -1763,12 +1782,15 @@ abstract class BaseImage extends BaseObject implements Persistent * * @param PropelCollection $imageI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Image The current object (for fluent API support) */ public function setImageI18ns(PropelCollection $imageI18ns, PropelPDO $con = null) { - $this->imageI18nsScheduledForDeletion = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns); + $imageI18nsToDelete = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns); - foreach ($this->imageI18nsScheduledForDeletion as $imageI18nRemoved) { + $this->imageI18nsScheduledForDeletion = unserialize(serialize($imageI18nsToDelete)); + + foreach ($imageI18nsToDelete as $imageI18nRemoved) { $imageI18nRemoved->setImage(null); } @@ -1779,6 +1801,8 @@ abstract class BaseImage extends BaseObject implements Persistent $this->collImageI18ns = $imageI18ns; $this->collImageI18nsPartial = false; + + return $this; } /** @@ -1796,22 +1820,22 @@ abstract class BaseImage extends BaseObject implements Persistent if (null === $this->collImageI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collImageI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getImageI18ns()); - } - $query = ImageI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByImage($this) - ->count($con); } - } else { - return count($this->collImageI18ns); + + if($partial && !$criteria) { + return count($this->getImageI18ns()); + } + $query = ImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByImage($this) + ->count($con); } + + return count($this->collImageI18ns); } /** @@ -1831,7 +1855,7 @@ abstract class BaseImage extends BaseObject implements Persistent $this->initImageI18ns(); $this->collImageI18nsPartial = true; } - if (!$this->collImageI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddImageI18n($l); } @@ -1849,6 +1873,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * @param ImageI18n $imageI18n The imageI18n object to remove. + * @return Image The current object (for fluent API support) */ public function removeImageI18n($imageI18n) { @@ -1858,9 +1883,11 @@ abstract class BaseImage extends BaseObject implements Persistent $this->imageI18nsScheduledForDeletion = clone $this->collImageI18ns; $this->imageI18nsScheduledForDeletion->clear(); } - $this->imageI18nsScheduledForDeletion[]= $imageI18n; + $this->imageI18nsScheduledForDeletion[]= clone $imageI18n; $imageI18n->setImage(null); } + + return $this; } /** @@ -1879,6 +1906,7 @@ abstract class BaseImage extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1896,16 +1924,31 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collImageI18ns) { foreach ($this->collImageI18ns as $o) { $o->clearAllReferences($deep); } } + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collImageI18ns instanceof PropelCollection) { @@ -1961,7 +2004,7 @@ abstract class BaseImage extends BaseObject implements Persistent * * @return Image The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1985,7 +2028,7 @@ abstract class BaseImage extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ImageI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collImageI18ns) { @@ -2020,7 +2063,7 @@ abstract class BaseImage extends BaseObject implements Persistent * * @return Image The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseImageI18n.php b/core/lib/Thelia/Model/om/BaseImageI18n.php index efadab3e7..bafb3b7bb 100644 --- a/core/lib/Thelia/Model/om/BaseImageI18n.php +++ b/core/lib/Thelia/Model/om/BaseImageI18n.php @@ -53,7 +53,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ImageI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseImageI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ImageI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ImageI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ImageI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ImageI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ImageI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ImageI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseImageI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseImageI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseImageI18n extends BaseObject implements Persistent * Get the associated Image object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Image The associated Image object. * @throws PropelException */ - public function getImage(PropelPDO $con = null) + public function getImage(PropelPDO $con = null, $doQuery = true) { - if ($this->aImage === null && ($this->id !== null)) { + if ($this->aImage === null && ($this->id !== null) && $doQuery) { $this->aImage = ImageQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseImageI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseImageI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aImage instanceof Persistent) { + $this->aImage->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aImage = null; diff --git a/core/lib/Thelia/Model/om/BaseImageI18nPeer.php b/core/lib/Thelia/Model/om/BaseImageI18nPeer.php index 61ce08b89..b831c19a1 100644 --- a/core/lib/Thelia/Model/om/BaseImageI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseImageI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseImageI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'image_i18n.ID'; + /** the column name for the id field */ + const ID = 'image_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'image_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'image_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'image_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'image_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'image_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'image_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'image_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'image_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'image_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'image_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseImageI18nPeer $criteria->addSelectColumn(ImageI18nPeer::CHAPO); $criteria->addSelectColumn(ImageI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseImageI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseImageI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ImageI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ImageI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseImageI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ImageI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php b/core/lib/Thelia/Model/om/BaseImageI18nQuery.php index cf4c865ea..be9c773a5 100644 --- a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseImageI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * Returns a new ImageI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ImageI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ImageI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ImageI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseImageI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ImageI18n A model object, or null if the key is not found - * @throws PropelException + * @return ImageI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `image_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `image_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseImageI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByImage() @@ -273,8 +274,22 @@ abstract class BaseImageI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ImageI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ImageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ImageI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseImageI18nQuery extends ModelCriteria * @param Image|PropelObjectCollection $image The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImage($image, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseImagePeer.php b/core/lib/Thelia/Model/om/BaseImagePeer.php index fe793bffb..cf991dbfd 100644 --- a/core/lib/Thelia/Model/om/BaseImagePeer.php +++ b/core/lib/Thelia/Model/om/BaseImagePeer.php @@ -49,32 +49,32 @@ abstract class BaseImagePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 9; - /** the column name for the ID field */ - const ID = 'image.ID'; + /** the column name for the id field */ + const ID = 'image.id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'image.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'image.product_id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'image.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'image.category_id'; - /** the column name for the FOLDER_ID field */ - const FOLDER_ID = 'image.FOLDER_ID'; + /** the column name for the folder_id field */ + const FOLDER_ID = 'image.folder_id'; - /** the column name for the CONTENT_ID field */ - const CONTENT_ID = 'image.CONTENT_ID'; + /** the column name for the content_id field */ + const CONTENT_ID = 'image.content_id'; - /** the column name for the FILE field */ - const FILE = 'image.FILE'; + /** the column name for the file field */ + const FILE = 'image.file'; - /** the column name for the POSITION field */ - const POSITION = 'image.POSITION'; + /** the column name for the position field */ + const POSITION = 'image.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'image.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'image.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'image.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'image.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -94,7 +94,7 @@ abstract class BaseImagePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -206,15 +206,15 @@ abstract class BaseImagePeer $criteria->addSelectColumn(ImagePeer::CREATED_AT); $criteria->addSelectColumn(ImagePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.FILE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.folder_id'); + $criteria->addSelectColumn($alias . '.content_id'); + $criteria->addSelectColumn($alias . '.file'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -298,7 +298,7 @@ abstract class BaseImagePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -403,8 +403,15 @@ abstract class BaseImagePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ImagePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ImagePeer::$instances = array(); } @@ -1917,7 +1924,7 @@ abstract class BaseImagePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ImagePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/om/BaseImageQuery.php index d1f143825..44279b45d 100644 --- a/core/lib/Thelia/Model/om/BaseImageQuery.php +++ b/core/lib/Thelia/Model/om/BaseImageQuery.php @@ -73,7 +73,6 @@ use Thelia\Model\Product; * @method Image findOne(PropelPDO $con = null) Return the first Image matching the query * @method Image findOneOrCreate(PropelPDO $con = null) Return the first Image matching the query, or a new Image object populated from the query conditions when no match is found * - * @method Image findOneById(int $id) Return the first Image filtered by the id column * @method Image findOneByProductId(int $product_id) Return the first Image filtered by the product_id column * @method Image findOneByCategoryId(int $category_id) Return the first Image filtered by the category_id column * @method Image findOneByFolderId(int $folder_id) Return the first Image filtered by the folder_id column @@ -113,7 +112,7 @@ abstract class BaseImageQuery extends ModelCriteria * Returns a new ImageQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ImageQuery|Criteria $criteria Optional Criteria to build the query from + * @param ImageQuery|Criteria $criteria Optional Criteria to build the query from * * @return ImageQuery */ @@ -169,6 +168,20 @@ abstract class BaseImageQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Image A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -176,12 +189,12 @@ abstract class BaseImageQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Image A model object, or null if the key is not found - * @throws PropelException + * @return Image A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `FILE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `image` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `product_id`, `category_id`, `folder_id`, `content_id`, `file`, `position`, `created_at`, `updated_at` FROM `image` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -277,7 +290,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -290,8 +304,22 @@ abstract class BaseImageQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ImagePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ImagePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ImagePeer::ID, $id, $comparison); @@ -304,7 +332,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -347,7 +376,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -390,7 +420,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterByFolderId(1234); // WHERE folder_id = 1234 * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 + * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 * * * @see filterByFolder() @@ -433,7 +464,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterByContentId(1234); // WHERE content_id = 1234 * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 + * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 * * * @see filterByContent() @@ -505,7 +537,8 @@ abstract class BaseImageQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -631,8 +664,8 @@ abstract class BaseImageQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -707,8 +740,8 @@ abstract class BaseImageQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -783,8 +816,8 @@ abstract class BaseImageQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { @@ -859,8 +892,8 @@ abstract class BaseImageQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { @@ -935,8 +968,8 @@ abstract class BaseImageQuery extends ModelCriteria * @param ImageI18n|PropelObjectCollection $imageI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ImageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImageI18n($imageI18n, $comparison = null) { @@ -1095,7 +1128,7 @@ abstract class BaseImageQuery extends ModelCriteria * * @return ImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ImageI18n'; @@ -1113,7 +1146,7 @@ abstract class BaseImageQuery extends ModelCriteria * * @return ImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1134,7 +1167,7 @@ abstract class BaseImageQuery extends ModelCriteria * * @return ImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseLang.php b/core/lib/Thelia/Model/om/BaseLang.php index 0f1a1a474..d54987f69 100644 --- a/core/lib/Thelia/Model/om/BaseLang.php +++ b/core/lib/Thelia/Model/om/BaseLang.php @@ -107,6 +107,12 @@ abstract class BaseLang extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -186,22 +192,25 @@ abstract class BaseLang extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -223,22 +232,25 @@ abstract class BaseLang extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -249,7 +261,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -270,7 +282,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -291,7 +303,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -312,7 +324,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -333,7 +345,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setUrl($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -354,7 +366,7 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function setByDefault($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -460,7 +472,7 @@ abstract class BaseLang extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = LangPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -685,28 +697,28 @@ abstract class BaseLang extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(LangPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(LangPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(LangPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(LangPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(LangPeer::URL)) { - $modifiedColumns[':p' . $index++] = '`URL`'; + $modifiedColumns[':p' . $index++] = '`url`'; } if ($this->isColumnModified(LangPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; + $modifiedColumns[':p' . $index++] = '`by_default`'; } if ($this->isColumnModified(LangPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(LangPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -719,28 +731,28 @@ abstract class BaseLang extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`URL`': + case '`url`': $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); break; - case '`BY_DEFAULT`': + case '`by_default`': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -811,11 +823,11 @@ abstract class BaseLang extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1177,6 +1189,7 @@ abstract class BaseLang extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1194,7 +1207,10 @@ abstract class BaseLang extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) } diff --git a/core/lib/Thelia/Model/om/BaseLangPeer.php b/core/lib/Thelia/Model/om/BaseLangPeer.php index 1019d0bd3..671fb9678 100644 --- a/core/lib/Thelia/Model/om/BaseLangPeer.php +++ b/core/lib/Thelia/Model/om/BaseLangPeer.php @@ -44,29 +44,29 @@ abstract class BaseLangPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'lang.ID'; + /** the column name for the id field */ + const ID = 'lang.id'; - /** the column name for the TITLE field */ - const TITLE = 'lang.TITLE'; + /** the column name for the title field */ + const TITLE = 'lang.title'; - /** the column name for the CODE field */ - const CODE = 'lang.CODE'; + /** the column name for the code field */ + const CODE = 'lang.code'; - /** the column name for the LOCALE field */ - const LOCALE = 'lang.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'lang.locale'; - /** the column name for the URL field */ - const URL = 'lang.URL'; + /** the column name for the url field */ + const URL = 'lang.url'; - /** the column name for the BY_DEFAULT field */ - const BY_DEFAULT = 'lang.BY_DEFAULT'; + /** the column name for the by_default field */ + const BY_DEFAULT = 'lang.by_default'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'lang.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'lang.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'lang.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'lang.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -190,14 +190,14 @@ abstract class BaseLangPeer $criteria->addSelectColumn(LangPeer::CREATED_AT); $criteria->addSelectColumn(LangPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.url'); + $criteria->addSelectColumn($alias . '.by_default'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -281,7 +281,7 @@ abstract class BaseLangPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -386,8 +386,15 @@ abstract class BaseLangPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (LangPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } LangPeer::$instances = array(); } @@ -522,7 +529,7 @@ abstract class BaseLangPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return LangPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/om/BaseLangQuery.php index 330887111..10105802e 100644 --- a/core/lib/Thelia/Model/om/BaseLangQuery.php +++ b/core/lib/Thelia/Model/om/BaseLangQuery.php @@ -44,7 +44,6 @@ use Thelia\Model\LangQuery; * @method Lang findOne(PropelPDO $con = null) Return the first Lang matching the query * @method Lang findOneOrCreate(PropelPDO $con = null) Return the first Lang matching the query, or a new Lang object populated from the query conditions when no match is found * - * @method Lang findOneById(int $id) Return the first Lang filtered by the id column * @method Lang findOneByTitle(string $title) Return the first Lang filtered by the title column * @method Lang findOneByCode(string $code) Return the first Lang filtered by the code column * @method Lang findOneByLocale(string $locale) Return the first Lang filtered by the locale column @@ -82,7 +81,7 @@ abstract class BaseLangQuery extends ModelCriteria * Returns a new LangQuery object. * * @param string $modelAlias The alias of a model in the query - * @param LangQuery|Criteria $criteria Optional Criteria to build the query from + * @param LangQuery|Criteria $criteria Optional Criteria to build the query from * * @return LangQuery */ @@ -138,6 +137,20 @@ abstract class BaseLangQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Lang A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -145,12 +158,12 @@ abstract class BaseLangQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Lang A model object, or null if the key is not found - * @throws PropelException + * @return Lang A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TITLE`, `CODE`, `LOCALE`, `URL`, `BY_DEFAULT`, `CREATED_AT`, `UPDATED_AT` FROM `lang` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `title`, `code`, `locale`, `url`, `by_default`, `created_at`, `updated_at` FROM `lang` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -246,7 +259,8 @@ abstract class BaseLangQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -259,8 +273,22 @@ abstract class BaseLangQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(LangPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(LangPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(LangPeer::ID, $id, $comparison); @@ -389,7 +417,8 @@ abstract class BaseLangQuery extends ModelCriteria * * $query->filterByByDefault(1234); // WHERE by_default = 1234 * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 + * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 * * * @param mixed $byDefault The value to use as filter. diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php index b12e23930..09686a988 100644 --- a/core/lib/Thelia/Model/om/BaseMessage.php +++ b/core/lib/Thelia/Model/om/BaseMessage.php @@ -133,13 +133,19 @@ abstract class BaseMessage extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -247,22 +253,25 @@ abstract class BaseMessage extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -284,22 +293,25 @@ abstract class BaseMessage extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -331,22 +343,25 @@ abstract class BaseMessage extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -367,7 +382,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -388,7 +403,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -409,7 +424,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setSecured($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -430,7 +445,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -497,7 +512,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -541,7 +556,7 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -606,7 +621,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 9; // 9 = MessagePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -831,7 +846,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->collMessageI18ns !== null) { foreach ($this->collMessageI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -848,7 +863,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->collMessageVersions !== null) { foreach ($this->collMessageVersions as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -881,31 +896,31 @@ abstract class BaseMessage extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(MessagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(MessagePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(MessagePeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`SECURED`'; + $modifiedColumns[':p' . $index++] = '`secured`'; } if ($this->isColumnModified(MessagePeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(MessagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(MessagePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(MessagePeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -918,31 +933,31 @@ abstract class BaseMessage extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`SECURED`': + case '`secured`': $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1013,11 +1028,11 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1448,13 +1463,15 @@ abstract class BaseMessage extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Message The current object (for fluent API support) * @see addMessageI18ns() */ public function clearMessageI18ns() { $this->collMessageI18ns = null; // important to set this to null since that means it is uninitialized $this->collMessageI18nsPartial = null; + + return $this; } /** @@ -1526,6 +1543,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->collMessageI18nsPartial = true; } + $collMessageI18ns->getInternalIterator()->rewind(); return $collMessageI18ns; } @@ -1553,12 +1571,15 @@ abstract class BaseMessage extends BaseObject implements Persistent * * @param PropelCollection $messageI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Message The current object (for fluent API support) */ public function setMessageI18ns(PropelCollection $messageI18ns, PropelPDO $con = null) { - $this->messageI18nsScheduledForDeletion = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns); + $messageI18nsToDelete = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns); - foreach ($this->messageI18nsScheduledForDeletion as $messageI18nRemoved) { + $this->messageI18nsScheduledForDeletion = unserialize(serialize($messageI18nsToDelete)); + + foreach ($messageI18nsToDelete as $messageI18nRemoved) { $messageI18nRemoved->setMessage(null); } @@ -1569,6 +1590,8 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->collMessageI18ns = $messageI18ns; $this->collMessageI18nsPartial = false; + + return $this; } /** @@ -1586,22 +1609,22 @@ abstract class BaseMessage extends BaseObject implements Persistent if (null === $this->collMessageI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collMessageI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getMessageI18ns()); - } - $query = MessageI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByMessage($this) - ->count($con); } - } else { - return count($this->collMessageI18ns); + + if($partial && !$criteria) { + return count($this->getMessageI18ns()); + } + $query = MessageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByMessage($this) + ->count($con); } + + return count($this->collMessageI18ns); } /** @@ -1621,7 +1644,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->initMessageI18ns(); $this->collMessageI18nsPartial = true; } - if (!$this->collMessageI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collMessageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddMessageI18n($l); } @@ -1639,6 +1662,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * @param MessageI18n $messageI18n The messageI18n object to remove. + * @return Message The current object (for fluent API support) */ public function removeMessageI18n($messageI18n) { @@ -1648,9 +1672,11 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->messageI18nsScheduledForDeletion = clone $this->collMessageI18ns; $this->messageI18nsScheduledForDeletion->clear(); } - $this->messageI18nsScheduledForDeletion[]= $messageI18n; + $this->messageI18nsScheduledForDeletion[]= clone $messageI18n; $messageI18n->setMessage(null); } + + return $this; } /** @@ -1659,13 +1685,15 @@ abstract class BaseMessage extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Message The current object (for fluent API support) * @see addMessageVersions() */ public function clearMessageVersions() { $this->collMessageVersions = null; // important to set this to null since that means it is uninitialized $this->collMessageVersionsPartial = null; + + return $this; } /** @@ -1737,6 +1765,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->collMessageVersionsPartial = true; } + $collMessageVersions->getInternalIterator()->rewind(); return $collMessageVersions; } @@ -1764,12 +1793,15 @@ abstract class BaseMessage extends BaseObject implements Persistent * * @param PropelCollection $messageVersions A Propel collection. * @param PropelPDO $con Optional connection object + * @return Message The current object (for fluent API support) */ public function setMessageVersions(PropelCollection $messageVersions, PropelPDO $con = null) { - $this->messageVersionsScheduledForDeletion = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions); + $messageVersionsToDelete = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions); - foreach ($this->messageVersionsScheduledForDeletion as $messageVersionRemoved) { + $this->messageVersionsScheduledForDeletion = unserialize(serialize($messageVersionsToDelete)); + + foreach ($messageVersionsToDelete as $messageVersionRemoved) { $messageVersionRemoved->setMessage(null); } @@ -1780,6 +1812,8 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->collMessageVersions = $messageVersions; $this->collMessageVersionsPartial = false; + + return $this; } /** @@ -1797,22 +1831,22 @@ abstract class BaseMessage extends BaseObject implements Persistent if (null === $this->collMessageVersions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collMessageVersions) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getMessageVersions()); - } - $query = MessageVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByMessage($this) - ->count($con); } - } else { - return count($this->collMessageVersions); + + if($partial && !$criteria) { + return count($this->getMessageVersions()); + } + $query = MessageVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByMessage($this) + ->count($con); } + + return count($this->collMessageVersions); } /** @@ -1828,7 +1862,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->initMessageVersions(); $this->collMessageVersionsPartial = true; } - if (!$this->collMessageVersions->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collMessageVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddMessageVersion($l); } @@ -1846,6 +1880,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * @param MessageVersion $messageVersion The messageVersion object to remove. + * @return Message The current object (for fluent API support) */ public function removeMessageVersion($messageVersion) { @@ -1855,9 +1890,11 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->messageVersionsScheduledForDeletion = clone $this->collMessageVersions; $this->messageVersionsScheduledForDeletion->clear(); } - $this->messageVersionsScheduledForDeletion[]= $messageVersion; + $this->messageVersionsScheduledForDeletion[]= clone $messageVersion; $messageVersion->setMessage(null); } + + return $this; } /** @@ -1876,6 +1913,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1894,7 +1932,8 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collMessageI18ns) { foreach ($this->collMessageI18ns as $o) { $o->clearAllReferences($deep); @@ -1905,10 +1944,12 @@ abstract class BaseMessage extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collMessageI18ns instanceof PropelCollection) { @@ -1964,7 +2005,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * * @return Message The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1988,7 +2029,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return MessageI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collMessageI18ns) { @@ -2023,7 +2064,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * * @return Message The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { MessageI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseMessageI18n.php b/core/lib/Thelia/Model/om/BaseMessageI18n.php index e4c98eff5..125134b75 100644 --- a/core/lib/Thelia/Model/om/BaseMessageI18n.php +++ b/core/lib/Thelia/Model/om/BaseMessageI18n.php @@ -53,7 +53,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -95,6 +95,12 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -103,7 +109,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -174,7 +180,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -199,7 +205,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -220,7 +226,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -241,7 +247,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -262,7 +268,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function setDescriptionHtml($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -285,7 +291,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -323,7 +329,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 5; // 5 = MessageI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -549,19 +555,19 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(MessageI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(MessageI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(MessageI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION_HTML)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION_HTML`'; + $modifiedColumns[':p' . $index++] = '`description_html`'; } $sql = sprintf( @@ -574,19 +580,19 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`DESCRIPTION_HTML`': + case '`description_html`': $stmt->bindValue($identifier, $this->description_html, PDO::PARAM_STR); break; } @@ -650,11 +656,11 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1040,12 +1046,13 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent * Get the associated Message object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Message The associated Message object. * @throws PropelException */ - public function getMessage(PropelPDO $con = null) + public function getMessage(PropelPDO $con = null, $doQuery = true) { - if ($this->aMessage === null && ($this->id !== null)) { + if ($this->aMessage === null && ($this->id !== null) && $doQuery) { $this->aMessage = MessageQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1071,6 +1078,7 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent $this->description_html = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1089,7 +1097,13 @@ abstract class BaseMessageI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aMessage instanceof Persistent) { + $this->aMessage->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aMessage = null; diff --git a/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php b/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php index 91cc5cd3f..6235fc484 100644 --- a/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php @@ -45,20 +45,20 @@ abstract class BaseMessageI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 5; - /** the column name for the ID field */ - const ID = 'message_i18n.ID'; + /** the column name for the id field */ + const ID = 'message_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'message_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'message_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'message_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'message_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'message_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'message_i18n.description'; - /** the column name for the DESCRIPTION_HTML field */ - const DESCRIPTION_HTML = 'message_i18n.DESCRIPTION_HTML'; + /** the column name for the description_html field */ + const DESCRIPTION_HTML = 'message_i18n.description_html'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -179,11 +179,11 @@ abstract class BaseMessageI18nPeer $criteria->addSelectColumn(MessageI18nPeer::DESCRIPTION); $criteria->addSelectColumn(MessageI18nPeer::DESCRIPTION_HTML); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.DESCRIPTION_HTML'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.description_html'); } } @@ -267,7 +267,7 @@ abstract class BaseMessageI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -372,8 +372,15 @@ abstract class BaseMessageI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (MessageI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } MessageI18nPeer::$instances = array(); } @@ -746,7 +753,7 @@ abstract class BaseMessageI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return MessageI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php b/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php index 0888e945f..8e584eece 100644 --- a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php @@ -77,7 +77,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * Returns a new MessageI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param MessageI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param MessageI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return MessageI18nQuery */ @@ -141,12 +141,12 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return MessageI18n A model object, or null if the key is not found - * @throws PropelException + * @return MessageI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `DESCRIPTION_HTML` FROM `message_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `description_html` FROM `message_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -254,7 +254,8 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByMessage() @@ -269,8 +270,22 @@ abstract class BaseMessageI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MessageI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MessageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(MessageI18nPeer::ID, $id, $comparison); @@ -398,8 +413,8 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * @param Message|PropelObjectCollection $message The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return MessageI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return MessageI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByMessage($message, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php index 487e319ae..fbb1e2966 100644 --- a/core/lib/Thelia/Model/om/BaseMessagePeer.php +++ b/core/lib/Thelia/Model/om/BaseMessagePeer.php @@ -46,32 +46,32 @@ abstract class BaseMessagePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 9; - /** the column name for the ID field */ - const ID = 'message.ID'; + /** the column name for the id field */ + const ID = 'message.id'; - /** the column name for the CODE field */ - const CODE = 'message.CODE'; + /** the column name for the code field */ + const CODE = 'message.code'; - /** the column name for the SECURED field */ - const SECURED = 'message.SECURED'; + /** the column name for the secured field */ + const SECURED = 'message.secured'; - /** the column name for the REF field */ - const REF = 'message.REF'; + /** the column name for the ref field */ + const REF = 'message.ref'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'message.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'message.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'message.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'message.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'message.VERSION'; + /** the column name for the version field */ + const VERSION = 'message.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'message.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'message.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'message.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'message.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -91,7 +91,7 @@ abstract class BaseMessagePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; // versionable behavior /** @@ -210,15 +210,15 @@ abstract class BaseMessagePeer $criteria->addSelectColumn(MessagePeer::VERSION_CREATED_AT); $criteria->addSelectColumn(MessagePeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.SECURED'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.secured'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -302,7 +302,7 @@ abstract class BaseMessagePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -407,8 +407,15 @@ abstract class BaseMessagePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (MessagePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } MessagePeer::$instances = array(); } @@ -549,7 +556,7 @@ abstract class BaseMessagePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return MessagePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php index 119544645..036f52130 100644 --- a/core/lib/Thelia/Model/om/BaseMessageQuery.php +++ b/core/lib/Thelia/Model/om/BaseMessageQuery.php @@ -58,7 +58,6 @@ use Thelia\Model\MessageVersion; * @method Message findOne(PropelPDO $con = null) Return the first Message matching the query * @method Message findOneOrCreate(PropelPDO $con = null) Return the first Message matching the query, or a new Message object populated from the query conditions when no match is found * - * @method Message findOneById(int $id) Return the first Message filtered by the id column * @method Message findOneByCode(string $code) Return the first Message filtered by the code column * @method Message findOneBySecured(int $secured) Return the first Message filtered by the secured column * @method Message findOneByRef(string $ref) Return the first Message filtered by the ref column @@ -98,7 +97,7 @@ abstract class BaseMessageQuery extends ModelCriteria * Returns a new MessageQuery object. * * @param string $modelAlias The alias of a model in the query - * @param MessageQuery|Criteria $criteria Optional Criteria to build the query from + * @param MessageQuery|Criteria $criteria Optional Criteria to build the query from * * @return MessageQuery */ @@ -154,6 +153,20 @@ abstract class BaseMessageQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Message A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -161,12 +174,12 @@ abstract class BaseMessageQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Message A model object, or null if the key is not found - * @throws PropelException + * @return Message A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `SECURED`, `REF`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `message` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `secured`, `ref`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `message` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -262,7 +275,8 @@ abstract class BaseMessageQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -275,8 +289,22 @@ abstract class BaseMessageQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MessagePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MessagePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(MessagePeer::ID, $id, $comparison); @@ -318,7 +346,8 @@ abstract class BaseMessageQuery extends ModelCriteria * * $query->filterBySecured(1234); // WHERE secured = 1234 * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34) - * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 + * $query->filterBySecured(array('min' => 12)); // WHERE secured >= 12 + * $query->filterBySecured(array('max' => 12)); // WHERE secured <= 12 * * * @param mixed $secured The value to use as filter. @@ -474,7 +503,8 @@ abstract class BaseMessageQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -586,8 +616,8 @@ abstract class BaseMessageQuery extends ModelCriteria * @param MessageI18n|PropelObjectCollection $messageI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return MessageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return MessageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByMessageI18n($messageI18n, $comparison = null) { @@ -660,8 +690,8 @@ abstract class BaseMessageQuery extends ModelCriteria * @param MessageVersion|PropelObjectCollection $messageVersion the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return MessageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return MessageQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByMessageVersion($messageVersion, $comparison = null) { @@ -820,7 +850,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * @return MessageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; @@ -838,7 +868,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * @return MessageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -859,7 +889,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * @return MessageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseMessageVersion.php b/core/lib/Thelia/Model/om/BaseMessageVersion.php index c09212cef..85d086827 100644 --- a/core/lib/Thelia/Model/om/BaseMessageVersion.php +++ b/core/lib/Thelia/Model/om/BaseMessageVersion.php @@ -121,6 +121,12 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -201,22 +207,25 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -238,22 +247,25 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -285,22 +297,25 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -321,7 +336,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -346,7 +361,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -367,7 +382,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setSecured($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -388,7 +403,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -455,7 +470,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -499,7 +514,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -564,7 +579,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 9; // 9 = MessageVersionPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -790,31 +805,31 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(MessageVersionPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(MessageVersionPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(MessageVersionPeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`SECURED`'; + $modifiedColumns[':p' . $index++] = '`secured`'; } if ($this->isColumnModified(MessageVersionPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(MessageVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(MessageVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(MessageVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(MessageVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -827,31 +842,31 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`SECURED`': + case '`secured`': $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -915,11 +930,11 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1345,12 +1360,13 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent * Get the associated Message object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Message The associated Message object. * @throws PropelException */ - public function getMessage(PropelPDO $con = null) + public function getMessage(PropelPDO $con = null, $doQuery = true) { - if ($this->aMessage === null && ($this->id !== null)) { + if ($this->aMessage === null && ($this->id !== null) && $doQuery) { $this->aMessage = MessageQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1380,6 +1396,7 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1398,7 +1415,13 @@ abstract class BaseMessageVersion extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aMessage instanceof Persistent) { + $this->aMessage->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aMessage = null; diff --git a/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php b/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php index 714607ebe..32862e04e 100644 --- a/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php +++ b/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php @@ -45,32 +45,32 @@ abstract class BaseMessageVersionPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 9; - /** the column name for the ID field */ - const ID = 'message_version.ID'; + /** the column name for the id field */ + const ID = 'message_version.id'; - /** the column name for the CODE field */ - const CODE = 'message_version.CODE'; + /** the column name for the code field */ + const CODE = 'message_version.code'; - /** the column name for the SECURED field */ - const SECURED = 'message_version.SECURED'; + /** the column name for the secured field */ + const SECURED = 'message_version.secured'; - /** the column name for the REF field */ - const REF = 'message_version.REF'; + /** the column name for the ref field */ + const REF = 'message_version.ref'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'message_version.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'message_version.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'message_version.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'message_version.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'message_version.VERSION'; + /** the column name for the version field */ + const VERSION = 'message_version.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'message_version.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'message_version.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'message_version.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'message_version.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -195,15 +195,15 @@ abstract class BaseMessageVersionPeer $criteria->addSelectColumn(MessageVersionPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(MessageVersionPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.SECURED'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.secured'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -287,7 +287,7 @@ abstract class BaseMessageVersionPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -392,8 +392,15 @@ abstract class BaseMessageVersionPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (MessageVersionPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } MessageVersionPeer::$instances = array(); } @@ -766,7 +773,7 @@ abstract class BaseMessageVersionPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return MessageVersionPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php b/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php index 19660e740..fc7cbec0c 100644 --- a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php +++ b/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php @@ -93,7 +93,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * Returns a new MessageVersionQuery object. * * @param string $modelAlias The alias of a model in the query - * @param MessageVersionQuery|Criteria $criteria Optional Criteria to build the query from + * @param MessageVersionQuery|Criteria $criteria Optional Criteria to build the query from * * @return MessageVersionQuery */ @@ -157,12 +157,12 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return MessageVersion A model object, or null if the key is not found - * @throws PropelException + * @return MessageVersion A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `SECURED`, `REF`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `message_version` WHERE `ID` = :p0 AND `VERSION` = :p1'; + $sql = 'SELECT `id`, `code`, `secured`, `ref`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `message_version` WHERE `id` = :p0 AND `version` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -270,7 +270,8 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByMessage() @@ -285,8 +286,22 @@ abstract class BaseMessageVersionQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MessageVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MessageVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(MessageVersionPeer::ID, $id, $comparison); @@ -328,7 +343,8 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $query->filterBySecured(1234); // WHERE secured = 1234 * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34) - * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 + * $query->filterBySecured(array('min' => 12)); // WHERE secured >= 12 + * $query->filterBySecured(array('max' => 12)); // WHERE secured <= 12 * * * @param mixed $secured The value to use as filter. @@ -484,7 +500,8 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -497,8 +514,22 @@ abstract class BaseMessageVersionQuery extends ModelCriteria */ public function filterByVersion($version = null, $comparison = null) { - if (is_array($version) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(MessageVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(MessageVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(MessageVersionPeer::VERSION, $version, $comparison); @@ -582,8 +613,8 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * @param Message|PropelObjectCollection $message The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return MessageVersionQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return MessageVersionQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByMessage($message, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseModule.php b/core/lib/Thelia/Model/om/BaseModule.php index 70696cf6f..a7526041e 100644 --- a/core/lib/Thelia/Model/om/BaseModule.php +++ b/core/lib/Thelia/Model/om/BaseModule.php @@ -119,13 +119,19 @@ abstract class BaseModule extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -214,22 +220,25 @@ abstract class BaseModule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -251,22 +260,25 @@ abstract class BaseModule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -277,7 +289,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -298,7 +310,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -319,7 +331,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function set type($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -340,7 +352,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function setActivate($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -361,7 +373,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -466,7 +478,7 @@ abstract class BaseModule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = ModulePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -680,7 +692,7 @@ abstract class BaseModule extends BaseObject implements Persistent if ($this->collGroupModules !== null) { foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -697,7 +709,7 @@ abstract class BaseModule extends BaseObject implements Persistent if ($this->collModuleI18ns !== null) { foreach ($this->collModuleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -726,25 +738,25 @@ abstract class BaseModule extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ModulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ModulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(ModulePeer:: TYPE)) { - $modifiedColumns[':p' . $index++] = '` TYPE`'; + $modifiedColumns[':p' . $index++] = '` type`'; } if ($this->isColumnModified(ModulePeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`ACTIVATE`'; + $modifiedColumns[':p' . $index++] = '`activate`'; } if ($this->isColumnModified(ModulePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ModulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ModulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -757,25 +769,25 @@ abstract class BaseModule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '` TYPE`': + case '` type`': $stmt->bindValue($identifier, $this-> type, PDO::PARAM_INT); break; - case '`ACTIVATE`': + case '`activate`': $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -839,11 +851,11 @@ abstract class BaseModule extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1254,13 +1266,15 @@ abstract class BaseModule extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Module The current object (for fluent API support) * @see addGroupModules() */ public function clearGroupModules() { $this->collGroupModules = null; // important to set this to null since that means it is uninitialized $this->collGroupModulesPartial = null; + + return $this; } /** @@ -1332,6 +1346,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->collGroupModulesPartial = true; } + $collGroupModules->getInternalIterator()->rewind(); return $collGroupModules; } @@ -1359,12 +1374,15 @@ abstract class BaseModule extends BaseObject implements Persistent * * @param PropelCollection $groupModules A Propel collection. * @param PropelPDO $con Optional connection object + * @return Module The current object (for fluent API support) */ public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) { - $this->groupModulesScheduledForDeletion = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); + $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - foreach ($this->groupModulesScheduledForDeletion as $groupModuleRemoved) { + $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); + + foreach ($groupModulesToDelete as $groupModuleRemoved) { $groupModuleRemoved->setModule(null); } @@ -1375,6 +1393,8 @@ abstract class BaseModule extends BaseObject implements Persistent $this->collGroupModules = $groupModules; $this->collGroupModulesPartial = false; + + return $this; } /** @@ -1392,22 +1412,22 @@ abstract class BaseModule extends BaseObject implements Persistent if (null === $this->collGroupModules || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupModules) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getGroupModules()); - } - $query = GroupModuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByModule($this) - ->count($con); } - } else { - return count($this->collGroupModules); + + if($partial && !$criteria) { + return count($this->getGroupModules()); + } + $query = GroupModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); } + + return count($this->collGroupModules); } /** @@ -1423,7 +1443,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->initGroupModules(); $this->collGroupModulesPartial = true; } - if (!$this->collGroupModules->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddGroupModule($l); } @@ -1441,6 +1461,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * @param GroupModule $groupModule The groupModule object to remove. + * @return Module The current object (for fluent API support) */ public function removeGroupModule($groupModule) { @@ -1453,6 +1474,8 @@ abstract class BaseModule extends BaseObject implements Persistent $this->groupModulesScheduledForDeletion[]= $groupModule; $groupModule->setModule(null); } + + return $this; } @@ -1486,13 +1509,15 @@ abstract class BaseModule extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Module The current object (for fluent API support) * @see addModuleI18ns() */ public function clearModuleI18ns() { $this->collModuleI18ns = null; // important to set this to null since that means it is uninitialized $this->collModuleI18nsPartial = null; + + return $this; } /** @@ -1564,6 +1589,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->collModuleI18nsPartial = true; } + $collModuleI18ns->getInternalIterator()->rewind(); return $collModuleI18ns; } @@ -1591,12 +1617,15 @@ abstract class BaseModule extends BaseObject implements Persistent * * @param PropelCollection $moduleI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Module The current object (for fluent API support) */ public function setModuleI18ns(PropelCollection $moduleI18ns, PropelPDO $con = null) { - $this->moduleI18nsScheduledForDeletion = $this->getModuleI18ns(new Criteria(), $con)->diff($moduleI18ns); + $moduleI18nsToDelete = $this->getModuleI18ns(new Criteria(), $con)->diff($moduleI18ns); - foreach ($this->moduleI18nsScheduledForDeletion as $moduleI18nRemoved) { + $this->moduleI18nsScheduledForDeletion = unserialize(serialize($moduleI18nsToDelete)); + + foreach ($moduleI18nsToDelete as $moduleI18nRemoved) { $moduleI18nRemoved->setModule(null); } @@ -1607,6 +1636,8 @@ abstract class BaseModule extends BaseObject implements Persistent $this->collModuleI18ns = $moduleI18ns; $this->collModuleI18nsPartial = false; + + return $this; } /** @@ -1624,22 +1655,22 @@ abstract class BaseModule extends BaseObject implements Persistent if (null === $this->collModuleI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collModuleI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getModuleI18ns()); - } - $query = ModuleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByModule($this) - ->count($con); } - } else { - return count($this->collModuleI18ns); + + if($partial && !$criteria) { + return count($this->getModuleI18ns()); + } + $query = ModuleI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); } + + return count($this->collModuleI18ns); } /** @@ -1659,7 +1690,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->initModuleI18ns(); $this->collModuleI18nsPartial = true; } - if (!$this->collModuleI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collModuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddModuleI18n($l); } @@ -1677,6 +1708,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * @param ModuleI18n $moduleI18n The moduleI18n object to remove. + * @return Module The current object (for fluent API support) */ public function removeModuleI18n($moduleI18n) { @@ -1686,9 +1718,11 @@ abstract class BaseModule extends BaseObject implements Persistent $this->moduleI18nsScheduledForDeletion = clone $this->collModuleI18ns; $this->moduleI18nsScheduledForDeletion->clear(); } - $this->moduleI18nsScheduledForDeletion[]= $moduleI18n; + $this->moduleI18nsScheduledForDeletion[]= clone $moduleI18n; $moduleI18n->setModule(null); } + + return $this; } /** @@ -1705,6 +1739,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1722,7 +1757,8 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collGroupModules) { foreach ($this->collGroupModules as $o) { $o->clearAllReferences($deep); @@ -1733,10 +1769,12 @@ abstract class BaseModule extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collGroupModules instanceof PropelCollection) { @@ -1792,7 +1830,7 @@ abstract class BaseModule extends BaseObject implements Persistent * * @return Module The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1816,7 +1854,7 @@ abstract class BaseModule extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ModuleI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { @@ -1851,7 +1889,7 @@ abstract class BaseModule extends BaseObject implements Persistent * * @return Module The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ModuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseModuleI18n.php b/core/lib/Thelia/Model/om/BaseModuleI18n.php index 567ba4306..dbddaeeed 100644 --- a/core/lib/Thelia/Model/om/BaseModuleI18n.php +++ b/core/lib/Thelia/Model/om/BaseModuleI18n.php @@ -53,7 +53,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ModuleI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ModuleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ModuleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ModuleI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ModuleI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ModuleI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ModuleI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent * Get the associated Module object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Module The associated Module object. * @throws PropelException */ - public function getModule(PropelPDO $con = null) + public function getModule(PropelPDO $con = null, $doQuery = true) { - if ($this->aModule === null && ($this->id !== null)) { + if ($this->aModule === null && ($this->id !== null) && $doQuery) { $this->aModule = ModuleQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseModuleI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aModule instanceof Persistent) { + $this->aModule->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aModule = null; diff --git a/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php b/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php index a34fa2bf4..8493e7eae 100644 --- a/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseModuleI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'module_i18n.ID'; + /** the column name for the id field */ + const ID = 'module_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'module_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'module_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'module_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'module_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'module_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'module_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'module_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'module_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'module_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'module_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseModuleI18nPeer $criteria->addSelectColumn(ModuleI18nPeer::CHAPO); $criteria->addSelectColumn(ModuleI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseModuleI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseModuleI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ModuleI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ModuleI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseModuleI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ModuleI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php b/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php index 90a7b8f8e..ca75f0050 100644 --- a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * Returns a new ModuleI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ModuleI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ModuleI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ModuleI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ModuleI18n A model object, or null if the key is not found - * @throws PropelException + * @return ModuleI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `module_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `module_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByModule() @@ -273,8 +274,22 @@ abstract class BaseModuleI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ModuleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ModuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ModuleI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * @param Module|PropelObjectCollection $module The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ModuleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ModuleI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByModule($module, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseModulePeer.php b/core/lib/Thelia/Model/om/BaseModulePeer.php index 90a2d0686..48938f90d 100644 --- a/core/lib/Thelia/Model/om/BaseModulePeer.php +++ b/core/lib/Thelia/Model/om/BaseModulePeer.php @@ -46,26 +46,26 @@ abstract class BaseModulePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'module.ID'; + /** the column name for the id field */ + const ID = 'module.id'; - /** the column name for the CODE field */ - const CODE = 'module.CODE'; + /** the column name for the code field */ + const CODE = 'module.code'; - /** the column name for the TYPE field */ - const TYPE = 'module. TYPE'; + /** the column name for the type field */ + const TYPE = 'module. type'; - /** the column name for the ACTIVATE field */ - const ACTIVATE = 'module.ACTIVATE'; + /** the column name for the activate field */ + const ACTIVATE = 'module.activate'; - /** the column name for the POSITION field */ - const POSITION = 'module.POSITION'; + /** the column name for the position field */ + const POSITION = 'module.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'module.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'module.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'module.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'module.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -85,7 +85,7 @@ abstract class BaseModulePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -195,13 +195,13 @@ abstract class BaseModulePeer $criteria->addSelectColumn(ModulePeer::CREATED_AT); $criteria->addSelectColumn(ModulePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '. TYPE'); - $criteria->addSelectColumn($alias . '.ACTIVATE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '. type'); + $criteria->addSelectColumn($alias . '.activate'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -285,7 +285,7 @@ abstract class BaseModulePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -390,8 +390,15 @@ abstract class BaseModulePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ModulePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ModulePeer::$instances = array(); } @@ -532,7 +539,7 @@ abstract class BaseModulePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ModulePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/om/BaseModuleQuery.php index 02e610571..aa0eaaff2 100644 --- a/core/lib/Thelia/Model/om/BaseModuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseModuleQuery.php @@ -54,7 +54,6 @@ use Thelia\Model\ModuleQuery; * @method Module findOne(PropelPDO $con = null) Return the first Module matching the query * @method Module findOneOrCreate(PropelPDO $con = null) Return the first Module matching the query, or a new Module object populated from the query conditions when no match is found * - * @method Module findOneById(int $id) Return the first Module filtered by the id column * @method Module findOneByCode(string $code) Return the first Module filtered by the code column * @method Module findOneBy type(int $ type) Return the first Module filtered by the type column * @method Module findOneByActivate(int $activate) Return the first Module filtered by the activate column @@ -90,7 +89,7 @@ abstract class BaseModuleQuery extends ModelCriteria * Returns a new ModuleQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ModuleQuery|Criteria $criteria Optional Criteria to build the query from + * @param ModuleQuery|Criteria $criteria Optional Criteria to build the query from * * @return ModuleQuery */ @@ -146,6 +145,20 @@ abstract class BaseModuleQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Module A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -153,12 +166,12 @@ abstract class BaseModuleQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Module A model object, or null if the key is not found - * @throws PropelException + * @return Module A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, ` TYPE`, `ACTIVATE`, `POSITION`, `CREATED_AT`, `UPDATED_AT` FROM `module` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, ` type`, `activate`, `position`, `created_at`, `updated_at` FROM `module` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -254,7 +267,8 @@ abstract class BaseModuleQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -267,8 +281,22 @@ abstract class BaseModuleQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ModulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ModulePeer::ID, $id, $comparison); @@ -310,7 +338,8 @@ abstract class BaseModuleQuery extends ModelCriteria * * $query->filterBy type(1234); // WHERE type = 1234 * $query->filterBy type(array(12, 34)); // WHERE type IN (12, 34) - * $query->filterBy type(array('min' => 12)); // WHERE type > 12 + * $query->filterBy type(array('min' => 12)); // WHERE type >= 12 + * $query->filterBy type(array('max' => 12)); // WHERE type <= 12 * * * @param mixed $ type The value to use as filter. @@ -351,7 +380,8 @@ abstract class BaseModuleQuery extends ModelCriteria * * $query->filterByActivate(1234); // WHERE activate = 1234 * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 + * $query->filterByActivate(array('min' => 12)); // WHERE activate >= 12 + * $query->filterByActivate(array('max' => 12)); // WHERE activate <= 12 * * * @param mixed $activate The value to use as filter. @@ -392,7 +422,8 @@ abstract class BaseModuleQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -518,8 +549,8 @@ abstract class BaseModuleQuery extends ModelCriteria * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ModuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroupModule($groupModule, $comparison = null) { @@ -592,8 +623,8 @@ abstract class BaseModuleQuery extends ModelCriteria * @param ModuleI18n|PropelObjectCollection $moduleI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ModuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByModuleI18n($moduleI18n, $comparison = null) { @@ -752,7 +783,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * @return ModuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; @@ -770,7 +801,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * @return ModuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -791,7 +822,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * @return ModuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/om/BaseOrder.php index 01ba6cc1a..9f3c72e34 100644 --- a/core/lib/Thelia/Model/om/BaseOrder.php +++ b/core/lib/Thelia/Model/om/BaseOrder.php @@ -218,6 +218,12 @@ abstract class BaseOrder extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -299,22 +305,25 @@ abstract class BaseOrder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->invoice_date); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->invoice_date, true), $x); - } + } + + try { + $dt = new DateTime($this->invoice_date); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->invoice_date, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -436,22 +445,25 @@ abstract class BaseOrder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -473,22 +485,25 @@ abstract class BaseOrder extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -499,7 +514,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -520,7 +535,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -541,7 +556,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setCustomerId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -566,7 +581,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setAddressInvoice($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -591,7 +606,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setAddressDelivery($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -639,7 +654,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setCurrencyId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -664,7 +679,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setCurrencyRate($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -685,7 +700,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setTransaction($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -706,7 +721,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setDeliveryNum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -727,7 +742,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setInvoice($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -748,7 +763,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setPostage($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -769,7 +784,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setPayment($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -790,7 +805,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setCarrier($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -811,7 +826,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setStatusId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -836,7 +851,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function setLang($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -952,7 +967,7 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 18; // 18 = OrderPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -1225,7 +1240,7 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($this->collOrderProducts !== null) { foreach ($this->collOrderProducts as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1242,7 +1257,7 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($this->collCouponOrders !== null) { foreach ($this->collCouponOrders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1275,58 +1290,58 @@ abstract class BaseOrder extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`CUSTOMER_ID`'; + $modifiedColumns[':p' . $index++] = '`customer_id`'; } if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS_INVOICE`'; + $modifiedColumns[':p' . $index++] = '`address_invoice`'; } if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS_DELIVERY`'; + $modifiedColumns[':p' . $index++] = '`address_delivery`'; } if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) { - $modifiedColumns[':p' . $index++] = '`INVOICE_DATE`'; + $modifiedColumns[':p' . $index++] = '`invoice_date`'; } if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) { - $modifiedColumns[':p' . $index++] = '`CURRENCY_ID`'; + $modifiedColumns[':p' . $index++] = '`currency_id`'; } if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) { - $modifiedColumns[':p' . $index++] = '`CURRENCY_RATE`'; + $modifiedColumns[':p' . $index++] = '`currency_rate`'; } if ($this->isColumnModified(OrderPeer::TRANSACTION)) { - $modifiedColumns[':p' . $index++] = '`TRANSACTION`'; + $modifiedColumns[':p' . $index++] = '`transaction`'; } if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) { - $modifiedColumns[':p' . $index++] = '`DELIVERY_NUM`'; + $modifiedColumns[':p' . $index++] = '`delivery_num`'; } if ($this->isColumnModified(OrderPeer::INVOICE)) { - $modifiedColumns[':p' . $index++] = '`INVOICE`'; + $modifiedColumns[':p' . $index++] = '`invoice`'; } if ($this->isColumnModified(OrderPeer::POSTAGE)) { - $modifiedColumns[':p' . $index++] = '`POSTAGE`'; + $modifiedColumns[':p' . $index++] = '`postage`'; } if ($this->isColumnModified(OrderPeer::PAYMENT)) { - $modifiedColumns[':p' . $index++] = '`PAYMENT`'; + $modifiedColumns[':p' . $index++] = '`payment`'; } if ($this->isColumnModified(OrderPeer::CARRIER)) { - $modifiedColumns[':p' . $index++] = '`CARRIER`'; + $modifiedColumns[':p' . $index++] = '`carrier`'; } if ($this->isColumnModified(OrderPeer::STATUS_ID)) { - $modifiedColumns[':p' . $index++] = '`STATUS_ID`'; + $modifiedColumns[':p' . $index++] = '`status_id`'; } if ($this->isColumnModified(OrderPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`LANG`'; + $modifiedColumns[':p' . $index++] = '`lang`'; } if ($this->isColumnModified(OrderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(OrderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -1339,58 +1354,58 @@ abstract class BaseOrder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`CUSTOMER_ID`': + case '`customer_id`': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case '`ADDRESS_INVOICE`': + case '`address_invoice`': $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT); break; - case '`ADDRESS_DELIVERY`': + case '`address_delivery`': $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT); break; - case '`INVOICE_DATE`': + case '`invoice_date`': $stmt->bindValue($identifier, $this->invoice_date, PDO::PARAM_STR); break; - case '`CURRENCY_ID`': + case '`currency_id`': $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); break; - case '`CURRENCY_RATE`': + case '`currency_rate`': $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); break; - case '`TRANSACTION`': + case '`transaction`': $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR); break; - case '`DELIVERY_NUM`': + case '`delivery_num`': $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR); break; - case '`INVOICE`': + case '`invoice`': $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR); break; - case '`POSTAGE`': + case '`postage`': $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; - case '`PAYMENT`': + case '`payment`': $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR); break; - case '`CARRIER`': + case '`carrier`': $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR); break; - case '`STATUS_ID`': + case '`status_id`': $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); break; - case '`LANG`': + case '`lang`': $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -1461,11 +1476,11 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -2044,12 +2059,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * Get the associated Currency object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Currency The associated Currency object. * @throws PropelException */ - public function getCurrency(PropelPDO $con = null) + public function getCurrency(PropelPDO $con = null, $doQuery = true) { - if ($this->aCurrency === null && ($this->currency_id !== null)) { + if ($this->aCurrency === null && ($this->currency_id !== null) && $doQuery) { $this->aCurrency = CurrencyQuery::create()->findPk($this->currency_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2095,12 +2111,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * Get the associated Customer object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Customer The associated Customer object. * @throws PropelException */ - public function getCustomer(PropelPDO $con = null) + public function getCustomer(PropelPDO $con = null, $doQuery = true) { - if ($this->aCustomer === null && ($this->customer_id !== null)) { + if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2146,12 +2163,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * Get the associated OrderAddress object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return OrderAddress The associated OrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressInvoice(PropelPDO $con = null) + public function getOrderAddressRelatedByAddressInvoice(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) { + if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null) && $doQuery) { $this->aOrderAddressRelatedByAddressInvoice = OrderAddressQuery::create()->findPk($this->address_invoice, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2197,12 +2215,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * Get the associated OrderAddress object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return OrderAddress The associated OrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressDelivery(PropelPDO $con = null) + public function getOrderAddressRelatedByAddressDelivery(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) { + if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null) && $doQuery) { $this->aOrderAddressRelatedByAddressDelivery = OrderAddressQuery::create()->findPk($this->address_delivery, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2248,12 +2267,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * Get the associated OrderStatus object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return OrderStatus The associated OrderStatus object. * @throws PropelException */ - public function getOrderStatus(PropelPDO $con = null) + public function getOrderStatus(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrderStatus === null && ($this->status_id !== null)) { + if ($this->aOrderStatus === null && ($this->status_id !== null) && $doQuery) { $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->status_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2292,13 +2312,15 @@ abstract class BaseOrder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Order The current object (for fluent API support) * @see addOrderProducts() */ public function clearOrderProducts() { $this->collOrderProducts = null; // important to set this to null since that means it is uninitialized $this->collOrderProductsPartial = null; + + return $this; } /** @@ -2370,6 +2392,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->collOrderProductsPartial = true; } + $collOrderProducts->getInternalIterator()->rewind(); return $collOrderProducts; } @@ -2397,12 +2420,15 @@ abstract class BaseOrder extends BaseObject implements Persistent * * @param PropelCollection $orderProducts A Propel collection. * @param PropelPDO $con Optional connection object + * @return Order The current object (for fluent API support) */ public function setOrderProducts(PropelCollection $orderProducts, PropelPDO $con = null) { - $this->orderProductsScheduledForDeletion = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts); + $orderProductsToDelete = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts); - foreach ($this->orderProductsScheduledForDeletion as $orderProductRemoved) { + $this->orderProductsScheduledForDeletion = unserialize(serialize($orderProductsToDelete)); + + foreach ($orderProductsToDelete as $orderProductRemoved) { $orderProductRemoved->setOrder(null); } @@ -2413,6 +2439,8 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->collOrderProducts = $orderProducts; $this->collOrderProductsPartial = false; + + return $this; } /** @@ -2430,22 +2458,22 @@ abstract class BaseOrder extends BaseObject implements Persistent if (null === $this->collOrderProducts || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrderProducts) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrderProducts()); - } - $query = OrderProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrder($this) - ->count($con); } - } else { - return count($this->collOrderProducts); + + if($partial && !$criteria) { + return count($this->getOrderProducts()); + } + $query = OrderProductQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrder($this) + ->count($con); } + + return count($this->collOrderProducts); } /** @@ -2461,7 +2489,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->initOrderProducts(); $this->collOrderProductsPartial = true; } - if (!$this->collOrderProducts->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrderProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrderProduct($l); } @@ -2479,6 +2507,7 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * @param OrderProduct $orderProduct The orderProduct object to remove. + * @return Order The current object (for fluent API support) */ public function removeOrderProduct($orderProduct) { @@ -2488,9 +2517,11 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->orderProductsScheduledForDeletion = clone $this->collOrderProducts; $this->orderProductsScheduledForDeletion->clear(); } - $this->orderProductsScheduledForDeletion[]= $orderProduct; + $this->orderProductsScheduledForDeletion[]= clone $orderProduct; $orderProduct->setOrder(null); } + + return $this; } /** @@ -2499,13 +2530,15 @@ abstract class BaseOrder extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Order The current object (for fluent API support) * @see addCouponOrders() */ public function clearCouponOrders() { $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized $this->collCouponOrdersPartial = null; + + return $this; } /** @@ -2577,6 +2610,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->collCouponOrdersPartial = true; } + $collCouponOrders->getInternalIterator()->rewind(); return $collCouponOrders; } @@ -2604,12 +2638,15 @@ abstract class BaseOrder extends BaseObject implements Persistent * * @param PropelCollection $couponOrders A Propel collection. * @param PropelPDO $con Optional connection object + * @return Order The current object (for fluent API support) */ public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null) { - $this->couponOrdersScheduledForDeletion = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); + $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - foreach ($this->couponOrdersScheduledForDeletion as $couponOrderRemoved) { + $this->couponOrdersScheduledForDeletion = unserialize(serialize($couponOrdersToDelete)); + + foreach ($couponOrdersToDelete as $couponOrderRemoved) { $couponOrderRemoved->setOrder(null); } @@ -2620,6 +2657,8 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->collCouponOrders = $couponOrders; $this->collCouponOrdersPartial = false; + + return $this; } /** @@ -2637,22 +2676,22 @@ abstract class BaseOrder extends BaseObject implements Persistent if (null === $this->collCouponOrders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCouponOrders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getCouponOrders()); - } - $query = CouponOrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrder($this) - ->count($con); } - } else { - return count($this->collCouponOrders); + + if($partial && !$criteria) { + return count($this->getCouponOrders()); + } + $query = CouponOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrder($this) + ->count($con); } + + return count($this->collCouponOrders); } /** @@ -2668,7 +2707,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->initCouponOrders(); $this->collCouponOrdersPartial = true; } - if (!$this->collCouponOrders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddCouponOrder($l); } @@ -2686,6 +2725,7 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * @param CouponOrder $couponOrder The couponOrder object to remove. + * @return Order The current object (for fluent API support) */ public function removeCouponOrder($couponOrder) { @@ -2695,9 +2735,11 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; $this->couponOrdersScheduledForDeletion->clear(); } - $this->couponOrdersScheduledForDeletion[]= $couponOrder; + $this->couponOrdersScheduledForDeletion[]= clone $couponOrder; $couponOrder->setOrder(null); } + + return $this; } /** @@ -2725,6 +2767,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2742,7 +2785,8 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collOrderProducts) { foreach ($this->collOrderProducts as $o) { $o->clearAllReferences($deep); @@ -2753,6 +2797,23 @@ abstract class BaseOrder extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aCurrency instanceof Persistent) { + $this->aCurrency->clearAllReferences($deep); + } + if ($this->aCustomer instanceof Persistent) { + $this->aCustomer->clearAllReferences($deep); + } + if ($this->aOrderAddressRelatedByAddressInvoice instanceof Persistent) { + $this->aOrderAddressRelatedByAddressInvoice->clearAllReferences($deep); + } + if ($this->aOrderAddressRelatedByAddressDelivery instanceof Persistent) { + $this->aOrderAddressRelatedByAddressDelivery->clearAllReferences($deep); + } + if ($this->aOrderStatus instanceof Persistent) { + $this->aOrderStatus->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collOrderProducts instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/om/BaseOrderAddress.php index eb384ec49..ac3339370 100644 --- a/core/lib/Thelia/Model/om/BaseOrderAddress.php +++ b/core/lib/Thelia/Model/om/BaseOrderAddress.php @@ -159,6 +159,12 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -310,22 +316,25 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -347,22 +356,25 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -373,7 +385,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -394,7 +406,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setCustomerTitleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -415,7 +427,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setCompany($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -436,7 +448,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setFirstname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -457,7 +469,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setLastname($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -478,7 +490,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setAddress1($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -499,7 +511,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setAddress2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -520,7 +532,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setAddress3($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -541,7 +553,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setZipcode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -562,7 +574,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setCity($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -583,7 +595,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setPhone($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -604,7 +616,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function setCountryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -716,7 +728,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 14; // 14 = OrderAddressPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -930,7 +942,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if ($this->collOrdersRelatedByAddressInvoice !== null) { foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -948,7 +960,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if ($this->collOrdersRelatedByAddressDelivery !== null) { foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -981,46 +993,46 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderAddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`CUSTOMER_TITLE_ID`'; + $modifiedColumns[':p' . $index++] = '`customer_title_id`'; } if ($this->isColumnModified(OrderAddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`COMPANY`'; + $modifiedColumns[':p' . $index++] = '`company`'; } if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`FIRSTNAME`'; + $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`LASTNAME`'; + $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS1`'; + $modifiedColumns[':p' . $index++] = '`address1`'; } if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS2`'; + $modifiedColumns[':p' . $index++] = '`address2`'; } if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`ADDRESS3`'; + $modifiedColumns[':p' . $index++] = '`address3`'; } if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`ZIPCODE`'; + $modifiedColumns[':p' . $index++] = '`zipcode`'; } if ($this->isColumnModified(OrderAddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`CITY`'; + $modifiedColumns[':p' . $index++] = '`city`'; } if ($this->isColumnModified(OrderAddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`PHONE`'; + $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`'; + $modifiedColumns[':p' . $index++] = '`country_id`'; } if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -1033,46 +1045,46 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CUSTOMER_TITLE_ID`': + case '`customer_title_id`': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`COMPANY`': + case '`company`': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`FIRSTNAME`': + case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`LASTNAME`': + case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`ADDRESS1`': + case '`address1`': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`ADDRESS2`': + case '`address2`': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`ADDRESS3`': + case '`address3`': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`ZIPCODE`': + case '`zipcode`': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`CITY`': + case '`city`': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`PHONE`': + case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`COUNTRY_ID`': + case '`country_id`': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -1143,11 +1155,11 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1628,13 +1640,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return OrderAddress The current object (for fluent API support) * @see addOrdersRelatedByAddressInvoice() */ public function clearOrdersRelatedByAddressInvoice() { $this->collOrdersRelatedByAddressInvoice = null; // important to set this to null since that means it is uninitialized $this->collOrdersRelatedByAddressInvoicePartial = null; + + return $this; } /** @@ -1706,6 +1720,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->collOrdersRelatedByAddressInvoicePartial = true; } + $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind(); return $collOrdersRelatedByAddressInvoice; } @@ -1733,12 +1748,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * * @param PropelCollection $ordersRelatedByAddressInvoice A Propel collection. * @param PropelPDO $con Optional connection object + * @return OrderAddress The current object (for fluent API support) */ public function setOrdersRelatedByAddressInvoice(PropelCollection $ordersRelatedByAddressInvoice, PropelPDO $con = null) { - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); + $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); - foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoiceRemoved) { + $this->ordersRelatedByAddressInvoiceScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressInvoiceToDelete)); + + foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) { $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null); } @@ -1749,6 +1767,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice; $this->collOrdersRelatedByAddressInvoicePartial = false; + + return $this; } /** @@ -1766,22 +1786,22 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressInvoice()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderAddressRelatedByAddressInvoice($this) - ->count($con); } - } else { - return count($this->collOrdersRelatedByAddressInvoice); + + if($partial && !$criteria) { + return count($this->getOrdersRelatedByAddressInvoice()); + } + $query = OrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderAddressRelatedByAddressInvoice($this) + ->count($con); } + + return count($this->collOrdersRelatedByAddressInvoice); } /** @@ -1797,7 +1817,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->initOrdersRelatedByAddressInvoice(); $this->collOrdersRelatedByAddressInvoicePartial = true; } - if (!$this->collOrdersRelatedByAddressInvoice->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrdersRelatedByAddressInvoice->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrderRelatedByAddressInvoice($l); } @@ -1815,6 +1835,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. + * @return OrderAddress The current object (for fluent API support) */ public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) { @@ -1827,6 +1848,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice; $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null); } + + return $this; } @@ -1910,13 +1933,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return OrderAddress The current object (for fluent API support) * @see addOrdersRelatedByAddressDelivery() */ public function clearOrdersRelatedByAddressDelivery() { $this->collOrdersRelatedByAddressDelivery = null; // important to set this to null since that means it is uninitialized $this->collOrdersRelatedByAddressDeliveryPartial = null; + + return $this; } /** @@ -1988,6 +2013,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->collOrdersRelatedByAddressDeliveryPartial = true; } + $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind(); return $collOrdersRelatedByAddressDelivery; } @@ -2015,12 +2041,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * * @param PropelCollection $ordersRelatedByAddressDelivery A Propel collection. * @param PropelPDO $con Optional connection object + * @return OrderAddress The current object (for fluent API support) */ public function setOrdersRelatedByAddressDelivery(PropelCollection $ordersRelatedByAddressDelivery, PropelPDO $con = null) { - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); + $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); - foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDeliveryRemoved) { + $this->ordersRelatedByAddressDeliveryScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressDeliveryToDelete)); + + foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) { $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null); } @@ -2031,6 +2060,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery; $this->collOrdersRelatedByAddressDeliveryPartial = false; + + return $this; } /** @@ -2048,22 +2079,22 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressDelivery()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderAddressRelatedByAddressDelivery($this) - ->count($con); } - } else { - return count($this->collOrdersRelatedByAddressDelivery); + + if($partial && !$criteria) { + return count($this->getOrdersRelatedByAddressDelivery()); + } + $query = OrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderAddressRelatedByAddressDelivery($this) + ->count($con); } + + return count($this->collOrdersRelatedByAddressDelivery); } /** @@ -2079,7 +2110,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->initOrdersRelatedByAddressDelivery(); $this->collOrdersRelatedByAddressDeliveryPartial = true; } - if (!$this->collOrdersRelatedByAddressDelivery->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrdersRelatedByAddressDelivery->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrderRelatedByAddressDelivery($l); } @@ -2097,6 +2128,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. + * @return OrderAddress The current object (for fluent API support) */ public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) { @@ -2109,6 +2141,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery; $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null); } + + return $this; } @@ -2207,6 +2241,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2224,7 +2259,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collOrdersRelatedByAddressInvoice) { foreach ($this->collOrdersRelatedByAddressInvoice as $o) { $o->clearAllReferences($deep); @@ -2235,6 +2271,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collOrdersRelatedByAddressInvoice instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php index eab7445dd..ab7a67728 100644 --- a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php @@ -45,47 +45,47 @@ abstract class BaseOrderAddressPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 14; - /** the column name for the ID field */ - const ID = 'order_address.ID'; + /** the column name for the id field */ + const ID = 'order_address.id'; - /** the column name for the CUSTOMER_TITLE_ID field */ - const CUSTOMER_TITLE_ID = 'order_address.CUSTOMER_TITLE_ID'; + /** the column name for the customer_title_id field */ + const CUSTOMER_TITLE_ID = 'order_address.customer_title_id'; - /** the column name for the COMPANY field */ - const COMPANY = 'order_address.COMPANY'; + /** the column name for the company field */ + const COMPANY = 'order_address.company'; - /** the column name for the FIRSTNAME field */ - const FIRSTNAME = 'order_address.FIRSTNAME'; + /** the column name for the firstname field */ + const FIRSTNAME = 'order_address.firstname'; - /** the column name for the LASTNAME field */ - const LASTNAME = 'order_address.LASTNAME'; + /** the column name for the lastname field */ + const LASTNAME = 'order_address.lastname'; - /** the column name for the ADDRESS1 field */ - const ADDRESS1 = 'order_address.ADDRESS1'; + /** the column name for the address1 field */ + const ADDRESS1 = 'order_address.address1'; - /** the column name for the ADDRESS2 field */ - const ADDRESS2 = 'order_address.ADDRESS2'; + /** the column name for the address2 field */ + const ADDRESS2 = 'order_address.address2'; - /** the column name for the ADDRESS3 field */ - const ADDRESS3 = 'order_address.ADDRESS3'; + /** the column name for the address3 field */ + const ADDRESS3 = 'order_address.address3'; - /** the column name for the ZIPCODE field */ - const ZIPCODE = 'order_address.ZIPCODE'; + /** the column name for the zipcode field */ + const ZIPCODE = 'order_address.zipcode'; - /** the column name for the CITY field */ - const CITY = 'order_address.CITY'; + /** the column name for the city field */ + const CITY = 'order_address.city'; - /** the column name for the PHONE field */ - const PHONE = 'order_address.PHONE'; + /** the column name for the phone field */ + const PHONE = 'order_address.phone'; - /** the column name for the COUNTRY_ID field */ - const COUNTRY_ID = 'order_address.COUNTRY_ID'; + /** the column name for the country_id field */ + const COUNTRY_ID = 'order_address.country_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'order_address.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'order_address.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_address.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'order_address.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -215,20 +215,20 @@ abstract class BaseOrderAddressPeer $criteria->addSelectColumn(OrderAddressPeer::CREATED_AT); $criteria->addSelectColumn(OrderAddressPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID'); - $criteria->addSelectColumn($alias . '.COMPANY'); - $criteria->addSelectColumn($alias . '.FIRSTNAME'); - $criteria->addSelectColumn($alias . '.LASTNAME'); - $criteria->addSelectColumn($alias . '.ADDRESS1'); - $criteria->addSelectColumn($alias . '.ADDRESS2'); - $criteria->addSelectColumn($alias . '.ADDRESS3'); - $criteria->addSelectColumn($alias . '.ZIPCODE'); - $criteria->addSelectColumn($alias . '.CITY'); - $criteria->addSelectColumn($alias . '.PHONE'); - $criteria->addSelectColumn($alias . '.COUNTRY_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.customer_title_id'); + $criteria->addSelectColumn($alias . '.company'); + $criteria->addSelectColumn($alias . '.firstname'); + $criteria->addSelectColumn($alias . '.lastname'); + $criteria->addSelectColumn($alias . '.address1'); + $criteria->addSelectColumn($alias . '.address2'); + $criteria->addSelectColumn($alias . '.address3'); + $criteria->addSelectColumn($alias . '.zipcode'); + $criteria->addSelectColumn($alias . '.city'); + $criteria->addSelectColumn($alias . '.phone'); + $criteria->addSelectColumn($alias . '.country_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -312,7 +312,7 @@ abstract class BaseOrderAddressPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -417,8 +417,15 @@ abstract class BaseOrderAddressPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderAddressPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderAddressPeer::$instances = array(); } @@ -559,7 +566,7 @@ abstract class BaseOrderAddressPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderAddressPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php index c571dd9cf..71b8135e5 100644 --- a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php @@ -67,7 +67,6 @@ use Thelia\Model\OrderAddressQuery; * @method OrderAddress findOne(PropelPDO $con = null) Return the first OrderAddress matching the query * @method OrderAddress findOneOrCreate(PropelPDO $con = null) Return the first OrderAddress matching the query, or a new OrderAddress object populated from the query conditions when no match is found * - * @method OrderAddress findOneById(int $id) Return the first OrderAddress filtered by the id column * @method OrderAddress findOneByCustomerTitleId(int $customer_title_id) Return the first OrderAddress filtered by the customer_title_id column * @method OrderAddress findOneByCompany(string $company) Return the first OrderAddress filtered by the company column * @method OrderAddress findOneByFirstname(string $firstname) Return the first OrderAddress filtered by the firstname column @@ -117,7 +116,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * Returns a new OrderAddressQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderAddressQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderAddressQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderAddressQuery */ @@ -173,6 +172,20 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return OrderAddress A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -180,12 +193,12 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return OrderAddress A model object, or null if the key is not found - * @throws PropelException + * @return OrderAddress A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CUSTOMER_TITLE_ID`, `COMPANY`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `ADDRESS3`, `ZIPCODE`, `CITY`, `PHONE`, `COUNTRY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `order_address` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `phone`, `country_id`, `created_at`, `updated_at` FROM `order_address` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -281,7 +294,8 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -294,8 +308,22 @@ abstract class BaseOrderAddressQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderAddressPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderAddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderAddressPeer::ID, $id, $comparison); @@ -308,7 +336,8 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 + * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 * * * @param mixed $customerTitleId The value to use as filter. @@ -610,7 +639,8 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $query->filterByCountryId(1234); // WHERE country_id = 1234 * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 + * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 * * * @param mixed $countryId The value to use as filter. @@ -736,8 +766,8 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * @param Order|PropelObjectCollection $order the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderAddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderAddressQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderRelatedByAddressInvoice($order, $comparison = null) { @@ -810,8 +840,8 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * @param Order|PropelObjectCollection $order the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderAddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderAddressQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderRelatedByAddressDelivery($order, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseOrderFeature.php b/core/lib/Thelia/Model/om/BaseOrderFeature.php index 038e1e462..20a5e584f 100644 --- a/core/lib/Thelia/Model/om/BaseOrderFeature.php +++ b/core/lib/Thelia/Model/om/BaseOrderFeature.php @@ -102,6 +102,12 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -161,22 +167,25 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -198,22 +207,25 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -224,7 +236,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -245,7 +257,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ public function setOrderProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -270,7 +282,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ public function setFeatureDesc($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -291,7 +303,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ public function setFeatureAvDesc($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -395,7 +407,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = OrderFeaturePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -636,22 +648,22 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderFeaturePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderFeaturePeer::ORDER_PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`ORDER_PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`order_product_id`'; } if ($this->isColumnModified(OrderFeaturePeer::FEATURE_DESC)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_DESC`'; + $modifiedColumns[':p' . $index++] = '`feature_desc`'; } if ($this->isColumnModified(OrderFeaturePeer::FEATURE_AV_DESC)) { - $modifiedColumns[':p' . $index++] = '`FEATURE_AV_DESC`'; + $modifiedColumns[':p' . $index++] = '`feature_av_desc`'; } if ($this->isColumnModified(OrderFeaturePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -664,22 +676,22 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ORDER_PRODUCT_ID`': + case '`order_product_id`': $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); break; - case '`FEATURE_DESC`': + case '`feature_desc`': $stmt->bindValue($identifier, $this->feature_desc, PDO::PARAM_STR); break; - case '`FEATURE_AV_DESC`': + case '`feature_av_desc`': $stmt->bindValue($identifier, $this->feature_av_desc, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -750,11 +762,11 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1143,12 +1155,13 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent * Get the associated OrderProduct object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return OrderProduct The associated OrderProduct object. * @throws PropelException */ - public function getOrderProduct(PropelPDO $con = null) + public function getOrderProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + if ($this->aOrderProduct === null && ($this->order_product_id !== null) && $doQuery) { $this->aOrderProduct = OrderProductQuery::create()->findPk($this->order_product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1175,6 +1188,7 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1192,7 +1206,13 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aOrderProduct instanceof Persistent) { + $this->aOrderProduct->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aOrderProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php index 08c6a6e47..a8cc553ad 100644 --- a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php @@ -45,23 +45,23 @@ abstract class BaseOrderFeaturePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'order_feature.ID'; + /** the column name for the id field */ + const ID = 'order_feature.id'; - /** the column name for the ORDER_PRODUCT_ID field */ - const ORDER_PRODUCT_ID = 'order_feature.ORDER_PRODUCT_ID'; + /** the column name for the order_product_id field */ + const ORDER_PRODUCT_ID = 'order_feature.order_product_id'; - /** the column name for the FEATURE_DESC field */ - const FEATURE_DESC = 'order_feature.FEATURE_DESC'; + /** the column name for the feature_desc field */ + const FEATURE_DESC = 'order_feature.feature_desc'; - /** the column name for the FEATURE_AV_DESC field */ - const FEATURE_AV_DESC = 'order_feature.FEATURE_AV_DESC'; + /** the column name for the feature_av_desc field */ + const FEATURE_AV_DESC = 'order_feature.feature_av_desc'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'order_feature.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'order_feature.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_feature.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'order_feature.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseOrderFeaturePeer $criteria->addSelectColumn(OrderFeaturePeer::CREATED_AT); $criteria->addSelectColumn(OrderFeaturePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.FEATURE_DESC'); - $criteria->addSelectColumn($alias . '.FEATURE_AV_DESC'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.order_product_id'); + $criteria->addSelectColumn($alias . '.feature_desc'); + $criteria->addSelectColumn($alias . '.feature_av_desc'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -272,7 +272,7 @@ abstract class BaseOrderFeaturePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseOrderFeaturePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderFeaturePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderFeaturePeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseOrderFeaturePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderFeaturePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php index 39cd77b29..41c1b48c5 100644 --- a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php @@ -47,7 +47,6 @@ use Thelia\Model\OrderProduct; * @method OrderFeature findOne(PropelPDO $con = null) Return the first OrderFeature matching the query * @method OrderFeature findOneOrCreate(PropelPDO $con = null) Return the first OrderFeature matching the query, or a new OrderFeature object populated from the query conditions when no match is found * - * @method OrderFeature findOneById(int $id) Return the first OrderFeature filtered by the id column * @method OrderFeature findOneByOrderProductId(int $order_product_id) Return the first OrderFeature filtered by the order_product_id column * @method OrderFeature findOneByFeatureDesc(string $feature_desc) Return the first OrderFeature filtered by the feature_desc column * @method OrderFeature findOneByFeatureAvDesc(string $feature_av_desc) Return the first OrderFeature filtered by the feature_av_desc column @@ -81,7 +80,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * Returns a new OrderFeatureQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderFeatureQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderFeatureQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderFeatureQuery */ @@ -137,6 +136,20 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return OrderFeature A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -144,12 +157,12 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return OrderFeature A model object, or null if the key is not found - * @throws PropelException + * @return OrderFeature A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ORDER_PRODUCT_ID`, `FEATURE_DESC`, `FEATURE_AV_DESC`, `CREATED_AT`, `UPDATED_AT` FROM `order_feature` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `order_product_id`, `feature_desc`, `feature_av_desc`, `created_at`, `updated_at` FROM `order_feature` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -245,7 +258,8 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -258,8 +272,22 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderFeaturePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderFeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderFeaturePeer::ID, $id, $comparison); @@ -272,7 +300,8 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) - * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id >= 12 + * $query->filterByOrderProductId(array('max' => 12)); // WHERE order_product_id <= 12 * * * @see filterByOrderProduct() @@ -458,8 +487,8 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * @param OrderProduct|PropelObjectCollection $orderProduct The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderFeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderFeatureQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderProduct($orderProduct, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseOrderPeer.php b/core/lib/Thelia/Model/om/BaseOrderPeer.php index bcf1dd95b..671a6a757 100644 --- a/core/lib/Thelia/Model/om/BaseOrderPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderPeer.php @@ -50,59 +50,59 @@ abstract class BaseOrderPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 18; - /** the column name for the ID field */ - const ID = 'order.ID'; + /** the column name for the id field */ + const ID = 'order.id'; - /** the column name for the REF field */ - const REF = 'order.REF'; + /** the column name for the ref field */ + const REF = 'order.ref'; - /** the column name for the CUSTOMER_ID field */ - const CUSTOMER_ID = 'order.CUSTOMER_ID'; + /** the column name for the customer_id field */ + const CUSTOMER_ID = 'order.customer_id'; - /** the column name for the ADDRESS_INVOICE field */ - const ADDRESS_INVOICE = 'order.ADDRESS_INVOICE'; + /** the column name for the address_invoice field */ + const ADDRESS_INVOICE = 'order.address_invoice'; - /** the column name for the ADDRESS_DELIVERY field */ - const ADDRESS_DELIVERY = 'order.ADDRESS_DELIVERY'; + /** the column name for the address_delivery field */ + const ADDRESS_DELIVERY = 'order.address_delivery'; - /** the column name for the INVOICE_DATE field */ - const INVOICE_DATE = 'order.INVOICE_DATE'; + /** the column name for the invoice_date field */ + const INVOICE_DATE = 'order.invoice_date'; - /** the column name for the CURRENCY_ID field */ - const CURRENCY_ID = 'order.CURRENCY_ID'; + /** the column name for the currency_id field */ + const CURRENCY_ID = 'order.currency_id'; - /** the column name for the CURRENCY_RATE field */ - const CURRENCY_RATE = 'order.CURRENCY_RATE'; + /** the column name for the currency_rate field */ + const CURRENCY_RATE = 'order.currency_rate'; - /** the column name for the TRANSACTION field */ - const TRANSACTION = 'order.TRANSACTION'; + /** the column name for the transaction field */ + const TRANSACTION = 'order.transaction'; - /** the column name for the DELIVERY_NUM field */ - const DELIVERY_NUM = 'order.DELIVERY_NUM'; + /** the column name for the delivery_num field */ + const DELIVERY_NUM = 'order.delivery_num'; - /** the column name for the INVOICE field */ - const INVOICE = 'order.INVOICE'; + /** the column name for the invoice field */ + const INVOICE = 'order.invoice'; - /** the column name for the POSTAGE field */ - const POSTAGE = 'order.POSTAGE'; + /** the column name for the postage field */ + const POSTAGE = 'order.postage'; - /** the column name for the PAYMENT field */ - const PAYMENT = 'order.PAYMENT'; + /** the column name for the payment field */ + const PAYMENT = 'order.payment'; - /** the column name for the CARRIER field */ - const CARRIER = 'order.CARRIER'; + /** the column name for the carrier field */ + const CARRIER = 'order.carrier'; - /** the column name for the STATUS_ID field */ - const STATUS_ID = 'order.STATUS_ID'; + /** the column name for the status_id field */ + const STATUS_ID = 'order.status_id'; - /** the column name for the LANG field */ - const LANG = 'order.LANG'; + /** the column name for the lang field */ + const LANG = 'order.lang'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'order.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'order.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'order.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -236,24 +236,24 @@ abstract class BaseOrderPeer $criteria->addSelectColumn(OrderPeer::CREATED_AT); $criteria->addSelectColumn(OrderPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); - $criteria->addSelectColumn($alias . '.ADDRESS_INVOICE'); - $criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY'); - $criteria->addSelectColumn($alias . '.INVOICE_DATE'); - $criteria->addSelectColumn($alias . '.CURRENCY_ID'); - $criteria->addSelectColumn($alias . '.CURRENCY_RATE'); - $criteria->addSelectColumn($alias . '.TRANSACTION'); - $criteria->addSelectColumn($alias . '.DELIVERY_NUM'); - $criteria->addSelectColumn($alias . '.INVOICE'); - $criteria->addSelectColumn($alias . '.POSTAGE'); - $criteria->addSelectColumn($alias . '.PAYMENT'); - $criteria->addSelectColumn($alias . '.CARRIER'); - $criteria->addSelectColumn($alias . '.STATUS_ID'); - $criteria->addSelectColumn($alias . '.LANG'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.customer_id'); + $criteria->addSelectColumn($alias . '.address_invoice'); + $criteria->addSelectColumn($alias . '.address_delivery'); + $criteria->addSelectColumn($alias . '.invoice_date'); + $criteria->addSelectColumn($alias . '.currency_id'); + $criteria->addSelectColumn($alias . '.currency_rate'); + $criteria->addSelectColumn($alias . '.transaction'); + $criteria->addSelectColumn($alias . '.delivery_num'); + $criteria->addSelectColumn($alias . '.invoice'); + $criteria->addSelectColumn($alias . '.postage'); + $criteria->addSelectColumn($alias . '.payment'); + $criteria->addSelectColumn($alias . '.carrier'); + $criteria->addSelectColumn($alias . '.status_id'); + $criteria->addSelectColumn($alias . '.lang'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -337,7 +337,7 @@ abstract class BaseOrderPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -442,8 +442,15 @@ abstract class BaseOrderPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderPeer::$instances = array(); } @@ -2357,7 +2364,7 @@ abstract class BaseOrderPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/om/BaseOrderProduct.php index fd2edc837..19c1993bc 100644 --- a/core/lib/Thelia/Model/om/BaseOrderProduct.php +++ b/core/lib/Thelia/Model/om/BaseOrderProduct.php @@ -148,6 +148,12 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -273,22 +279,25 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -310,22 +319,25 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -336,7 +348,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -357,7 +369,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setOrderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -382,7 +394,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setProductRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -403,7 +415,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -424,7 +436,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -445,7 +457,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -466,7 +478,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setQuantity($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -487,7 +499,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setPrice($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -508,7 +520,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setTax($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -529,7 +541,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function setParent($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -639,7 +651,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 12; // 12 = OrderProductPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -866,7 +878,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if ($this->collOrderFeatures !== null) { foreach ($this->collOrderFeatures as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -899,40 +911,40 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = '`ORDER_ID`'; + $modifiedColumns[':p' . $index++] = '`order_id`'; } if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_REF`'; + $modifiedColumns[':p' . $index++] = '`product_ref`'; } if ($this->isColumnModified(OrderProductPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(OrderProductPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(OrderProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`QUANTITY`'; + $modifiedColumns[':p' . $index++] = '`quantity`'; } if ($this->isColumnModified(OrderProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`PRICE`'; + $modifiedColumns[':p' . $index++] = '`price`'; } if ($this->isColumnModified(OrderProductPeer::TAX)) { - $modifiedColumns[':p' . $index++] = '`TAX`'; + $modifiedColumns[':p' . $index++] = '`tax`'; } if ($this->isColumnModified(OrderProductPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`PARENT`'; + $modifiedColumns[':p' . $index++] = '`parent`'; } if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -945,40 +957,40 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ORDER_ID`': + case '`order_id`': $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); break; - case '`PRODUCT_REF`': + case '`product_ref`': $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`QUANTITY`': + case '`quantity`': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); break; - case '`PRICE`': + case '`price`': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`TAX`': + case '`tax`': $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); break; - case '`PARENT`': + case '`parent`': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -1049,11 +1061,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1519,12 +1531,13 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * Get the associated Order object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Order The associated Order object. * @throws PropelException */ - public function getOrder(PropelPDO $con = null) + public function getOrder(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrder === null && ($this->order_id !== null)) { + if ($this->aOrder === null && ($this->order_id !== null) && $doQuery) { $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1560,13 +1573,15 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return OrderProduct The current object (for fluent API support) * @see addOrderFeatures() */ public function clearOrderFeatures() { $this->collOrderFeatures = null; // important to set this to null since that means it is uninitialized $this->collOrderFeaturesPartial = null; + + return $this; } /** @@ -1638,6 +1653,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->collOrderFeaturesPartial = true; } + $collOrderFeatures->getInternalIterator()->rewind(); return $collOrderFeatures; } @@ -1665,12 +1681,15 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * * @param PropelCollection $orderFeatures A Propel collection. * @param PropelPDO $con Optional connection object + * @return OrderProduct The current object (for fluent API support) */ public function setOrderFeatures(PropelCollection $orderFeatures, PropelPDO $con = null) { - $this->orderFeaturesScheduledForDeletion = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); + $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); - foreach ($this->orderFeaturesScheduledForDeletion as $orderFeatureRemoved) { + $this->orderFeaturesScheduledForDeletion = unserialize(serialize($orderFeaturesToDelete)); + + foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { $orderFeatureRemoved->setOrderProduct(null); } @@ -1681,6 +1700,8 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->collOrderFeatures = $orderFeatures; $this->collOrderFeaturesPartial = false; + + return $this; } /** @@ -1698,22 +1719,22 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if (null === $this->collOrderFeatures || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrderFeatures) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrderFeatures()); - } - $query = OrderFeatureQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderProduct($this) - ->count($con); } - } else { - return count($this->collOrderFeatures); + + if($partial && !$criteria) { + return count($this->getOrderFeatures()); + } + $query = OrderFeatureQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderProduct($this) + ->count($con); } + + return count($this->collOrderFeatures); } /** @@ -1729,7 +1750,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->initOrderFeatures(); $this->collOrderFeaturesPartial = true; } - if (!$this->collOrderFeatures->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrderFeature($l); } @@ -1747,6 +1768,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * @param OrderFeature $orderFeature The orderFeature object to remove. + * @return OrderProduct The current object (for fluent API support) */ public function removeOrderFeature($orderFeature) { @@ -1756,9 +1778,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures; $this->orderFeaturesScheduledForDeletion->clear(); } - $this->orderFeaturesScheduledForDeletion[]= $orderFeature; + $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature; $orderFeature->setOrderProduct(null); } + + return $this; } /** @@ -1780,6 +1804,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1797,12 +1822,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collOrderFeatures) { foreach ($this->collOrderFeatures as $o) { $o->clearAllReferences($deep); } } + if ($this->aOrder instanceof Persistent) { + $this->aOrder->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collOrderFeatures instanceof PropelCollection) { diff --git a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php index 35a94e6c3..f0e91ddff 100644 --- a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php @@ -46,41 +46,41 @@ abstract class BaseOrderProductPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 12; - /** the column name for the ID field */ - const ID = 'order_product.ID'; + /** the column name for the id field */ + const ID = 'order_product.id'; - /** the column name for the ORDER_ID field */ - const ORDER_ID = 'order_product.ORDER_ID'; + /** the column name for the order_id field */ + const ORDER_ID = 'order_product.order_id'; - /** the column name for the PRODUCT_REF field */ - const PRODUCT_REF = 'order_product.PRODUCT_REF'; + /** the column name for the product_ref field */ + const PRODUCT_REF = 'order_product.product_ref'; - /** the column name for the TITLE field */ - const TITLE = 'order_product.TITLE'; + /** the column name for the title field */ + const TITLE = 'order_product.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'order_product.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'order_product.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'order_product.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'order_product.chapo'; - /** the column name for the QUANTITY field */ - const QUANTITY = 'order_product.QUANTITY'; + /** the column name for the quantity field */ + const QUANTITY = 'order_product.quantity'; - /** the column name for the PRICE field */ - const PRICE = 'order_product.PRICE'; + /** the column name for the price field */ + const PRICE = 'order_product.price'; - /** the column name for the TAX field */ - const TAX = 'order_product.TAX'; + /** the column name for the tax field */ + const TAX = 'order_product.tax'; - /** the column name for the PARENT field */ - const PARENT = 'order_product.PARENT'; + /** the column name for the parent field */ + const PARENT = 'order_product.parent'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'order_product.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'order_product.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_product.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'order_product.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -208,18 +208,18 @@ abstract class BaseOrderProductPeer $criteria->addSelectColumn(OrderProductPeer::CREATED_AT); $criteria->addSelectColumn(OrderProductPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ORDER_ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_REF'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.QUANTITY'); - $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.TAX'); - $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.order_id'); + $criteria->addSelectColumn($alias . '.product_ref'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.quantity'); + $criteria->addSelectColumn($alias . '.price'); + $criteria->addSelectColumn($alias . '.tax'); + $criteria->addSelectColumn($alias . '.parent'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -303,7 +303,7 @@ abstract class BaseOrderProductPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -408,8 +408,15 @@ abstract class BaseOrderProductPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderProductPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderProductPeer::$instances = array(); } @@ -785,7 +792,7 @@ abstract class BaseOrderProductPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderProductPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php index faac148d3..b93c39cce 100644 --- a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php @@ -64,7 +64,6 @@ use Thelia\Model\OrderProductQuery; * @method OrderProduct findOne(PropelPDO $con = null) Return the first OrderProduct matching the query * @method OrderProduct findOneOrCreate(PropelPDO $con = null) Return the first OrderProduct matching the query, or a new OrderProduct object populated from the query conditions when no match is found * - * @method OrderProduct findOneById(int $id) Return the first OrderProduct filtered by the id column * @method OrderProduct findOneByOrderId(int $order_id) Return the first OrderProduct filtered by the order_id column * @method OrderProduct findOneByProductRef(string $product_ref) Return the first OrderProduct filtered by the product_ref column * @method OrderProduct findOneByTitle(string $title) Return the first OrderProduct filtered by the title column @@ -110,7 +109,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * Returns a new OrderProductQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderProductQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderProductQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderProductQuery */ @@ -166,6 +165,20 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return OrderProduct A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -173,12 +186,12 @@ abstract class BaseOrderProductQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return OrderProduct A model object, or null if the key is not found - * @throws PropelException + * @return OrderProduct A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `ORDER_ID`, `PRODUCT_REF`, `TITLE`, `DESCRIPTION`, `CHAPO`, `QUANTITY`, `PRICE`, `TAX`, `PARENT`, `CREATED_AT`, `UPDATED_AT` FROM `order_product` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `order_id`, `product_ref`, `title`, `description`, `chapo`, `quantity`, `price`, `tax`, `parent`, `created_at`, `updated_at` FROM `order_product` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -274,7 +287,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -287,8 +301,22 @@ abstract class BaseOrderProductQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderProductPeer::ID, $id, $comparison); @@ -301,7 +329,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterByOrderId(1234); // WHERE order_id = 1234 * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) - * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id >= 12 + * $query->filterByOrderId(array('max' => 12)); // WHERE order_id <= 12 * * * @see filterByOrder() @@ -460,7 +489,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterByQuantity(1234); // WHERE quantity = 1234 * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) - * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 + * $query->filterByQuantity(array('min' => 12)); // WHERE quantity >= 12 + * $query->filterByQuantity(array('max' => 12)); // WHERE quantity <= 12 * * * @param mixed $quantity The value to use as filter. @@ -501,7 +531,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterByPrice(1234); // WHERE price = 1234 * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) - * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 + * $query->filterByPrice(array('min' => 12)); // WHERE price >= 12 + * $query->filterByPrice(array('max' => 12)); // WHERE price <= 12 * * * @param mixed $price The value to use as filter. @@ -542,7 +573,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterByTax(1234); // WHERE tax = 1234 * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 + * $query->filterByTax(array('min' => 12)); // WHERE tax >= 12 + * $query->filterByTax(array('max' => 12)); // WHERE tax <= 12 * * * @param mixed $tax The value to use as filter. @@ -583,7 +615,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $query->filterByParent(1234); // WHERE parent = 1234 * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 + * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 * * * @param mixed $parent The value to use as filter. @@ -709,8 +742,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * @param Order|PropelObjectCollection $order The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrder($order, $comparison = null) { @@ -785,8 +818,8 @@ abstract class BaseOrderProductQuery extends ModelCriteria * @param OrderFeature|PropelObjectCollection $orderFeature the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderFeature($orderFeature, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/om/BaseOrderQuery.php index 765347d96..c0e630548 100644 --- a/core/lib/Thelia/Model/om/BaseOrderQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderQuery.php @@ -100,7 +100,6 @@ use Thelia\Model\OrderStatus; * @method Order findOne(PropelPDO $con = null) Return the first Order matching the query * @method Order findOneOrCreate(PropelPDO $con = null) Return the first Order matching the query, or a new Order object populated from the query conditions when no match is found * - * @method Order findOneById(int $id) Return the first Order filtered by the id column * @method Order findOneByRef(string $ref) Return the first Order filtered by the ref column * @method Order findOneByCustomerId(int $customer_id) Return the first Order filtered by the customer_id column * @method Order findOneByAddressInvoice(int $address_invoice) Return the first Order filtered by the address_invoice column @@ -158,7 +157,7 @@ abstract class BaseOrderQuery extends ModelCriteria * Returns a new OrderQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderQuery */ @@ -214,6 +213,20 @@ abstract class BaseOrderQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Order A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -221,12 +234,12 @@ abstract class BaseOrderQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Order A model object, or null if the key is not found - * @throws PropelException + * @return Order A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `REF`, `CUSTOMER_ID`, `ADDRESS_INVOICE`, `ADDRESS_DELIVERY`, `INVOICE_DATE`, `CURRENCY_ID`, `CURRENCY_RATE`, `TRANSACTION`, `DELIVERY_NUM`, `INVOICE`, `POSTAGE`, `PAYMENT`, `CARRIER`, `STATUS_ID`, `LANG`, `CREATED_AT`, `UPDATED_AT` FROM `order` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `ref`, `customer_id`, `address_invoice`, `address_delivery`, `invoice_date`, `currency_id`, `currency_rate`, `transaction`, `delivery_num`, `invoice`, `postage`, `payment`, `carrier`, `status_id`, `lang`, `created_at`, `updated_at` FROM `order` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -322,7 +335,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -335,8 +349,22 @@ abstract class BaseOrderQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderPeer::ID, $id, $comparison); @@ -378,7 +406,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByCustomerId(1234); // WHERE customer_id = 1234 * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34) - * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12 + * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12 + * $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12 * * * @see filterByCustomer() @@ -421,7 +450,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234 * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34) - * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12 + * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice >= 12 + * $query->filterByAddressInvoice(array('max' => 12)); // WHERE address_invoice <= 12 * * * @see filterByOrderAddressRelatedByAddressInvoice() @@ -464,7 +494,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234 * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34) - * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12 + * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery >= 12 + * $query->filterByAddressDelivery(array('max' => 12)); // WHERE address_delivery <= 12 * * * @see filterByOrderAddressRelatedByAddressDelivery() @@ -550,7 +581,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234 * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34) - * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12 + * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id >= 12 + * $query->filterByCurrencyId(array('max' => 12)); // WHERE currency_id <= 12 * * * @see filterByCurrency() @@ -593,7 +625,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234 * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34) - * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12 + * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate >= 12 + * $query->filterByCurrencyRate(array('max' => 12)); // WHERE currency_rate <= 12 * * * @param mixed $currencyRate The value to use as filter. @@ -721,7 +754,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByPostage(1234); // WHERE postage = 1234 * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34) - * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12 + * $query->filterByPostage(array('min' => 12)); // WHERE postage >= 12 + * $query->filterByPostage(array('max' => 12)); // WHERE postage <= 12 * * * @param mixed $postage The value to use as filter. @@ -820,7 +854,8 @@ abstract class BaseOrderQuery extends ModelCriteria * * $query->filterByStatusId(1234); // WHERE status_id = 1234 * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34) - * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12 + * $query->filterByStatusId(array('min' => 12)); // WHERE status_id >= 12 + * $query->filterByStatusId(array('max' => 12)); // WHERE status_id <= 12 * * * @see filterByOrderStatus() @@ -977,8 +1012,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param Currency|PropelObjectCollection $currency The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCurrency($currency, $comparison = null) { @@ -1053,8 +1088,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCustomer($customer, $comparison = null) { @@ -1129,8 +1164,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null) { @@ -1205,8 +1240,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null) { @@ -1281,8 +1316,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderStatus($orderStatus, $comparison = null) { @@ -1357,8 +1392,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param OrderProduct|PropelObjectCollection $orderProduct the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderProduct($orderProduct, $comparison = null) { @@ -1431,8 +1466,8 @@ abstract class BaseOrderQuery extends ModelCriteria * @param CouponOrder|PropelObjectCollection $couponOrder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCouponOrder($couponOrder, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/om/BaseOrderStatus.php index d9859ff64..2654069e2 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatus.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatus.php @@ -101,13 +101,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -166,22 +172,25 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -203,22 +212,25 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -229,7 +241,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -250,7 +262,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -352,7 +364,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = OrderStatusPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -566,7 +578,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($this->collOrders !== null) { foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -583,7 +595,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($this->collOrderStatusI18ns !== null) { foreach ($this->collOrderStatusI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -616,16 +628,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderStatusPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderStatusPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -638,16 +650,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -718,11 +730,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1103,13 +1115,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return OrderStatus The current object (for fluent API support) * @see addOrders() */ public function clearOrders() { $this->collOrders = null; // important to set this to null since that means it is uninitialized $this->collOrdersPartial = null; + + return $this; } /** @@ -1181,6 +1195,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->collOrdersPartial = true; } + $collOrders->getInternalIterator()->rewind(); return $collOrders; } @@ -1208,12 +1223,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * @param PropelCollection $orders A Propel collection. * @param PropelPDO $con Optional connection object + * @return OrderStatus The current object (for fluent API support) */ public function setOrders(PropelCollection $orders, PropelPDO $con = null) { - $this->ordersScheduledForDeletion = $this->getOrders(new Criteria(), $con)->diff($orders); + $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - foreach ($this->ordersScheduledForDeletion as $orderRemoved) { + $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setOrderStatus(null); } @@ -1224,6 +1242,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->collOrders = $orders; $this->collOrdersPartial = false; + + return $this; } /** @@ -1241,22 +1261,22 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if (null === $this->collOrders || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrders) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderStatus($this) - ->count($con); } - } else { - return count($this->collOrders); + + if($partial && !$criteria) { + return count($this->getOrders()); + } + $query = OrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderStatus($this) + ->count($con); } + + return count($this->collOrders); } /** @@ -1272,7 +1292,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->initOrders(); $this->collOrdersPartial = true; } - if (!$this->collOrders->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrder($l); } @@ -1290,6 +1310,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * @param Order $order The order object to remove. + * @return OrderStatus The current object (for fluent API support) */ public function removeOrder($order) { @@ -1302,6 +1323,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->ordersScheduledForDeletion[]= $order; $order->setOrderStatus(null); } + + return $this; } @@ -1410,13 +1433,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return OrderStatus The current object (for fluent API support) * @see addOrderStatusI18ns() */ public function clearOrderStatusI18ns() { $this->collOrderStatusI18ns = null; // important to set this to null since that means it is uninitialized $this->collOrderStatusI18nsPartial = null; + + return $this; } /** @@ -1488,6 +1513,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->collOrderStatusI18nsPartial = true; } + $collOrderStatusI18ns->getInternalIterator()->rewind(); return $collOrderStatusI18ns; } @@ -1515,12 +1541,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * @param PropelCollection $orderStatusI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return OrderStatus The current object (for fluent API support) */ public function setOrderStatusI18ns(PropelCollection $orderStatusI18ns, PropelPDO $con = null) { - $this->orderStatusI18nsScheduledForDeletion = $this->getOrderStatusI18ns(new Criteria(), $con)->diff($orderStatusI18ns); + $orderStatusI18nsToDelete = $this->getOrderStatusI18ns(new Criteria(), $con)->diff($orderStatusI18ns); - foreach ($this->orderStatusI18nsScheduledForDeletion as $orderStatusI18nRemoved) { + $this->orderStatusI18nsScheduledForDeletion = unserialize(serialize($orderStatusI18nsToDelete)); + + foreach ($orderStatusI18nsToDelete as $orderStatusI18nRemoved) { $orderStatusI18nRemoved->setOrderStatus(null); } @@ -1531,6 +1560,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->collOrderStatusI18ns = $orderStatusI18ns; $this->collOrderStatusI18nsPartial = false; + + return $this; } /** @@ -1548,22 +1579,22 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collOrderStatusI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getOrderStatusI18ns()); - } - $query = OrderStatusI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderStatus($this) - ->count($con); } - } else { - return count($this->collOrderStatusI18ns); + + if($partial && !$criteria) { + return count($this->getOrderStatusI18ns()); + } + $query = OrderStatusI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderStatus($this) + ->count($con); } + + return count($this->collOrderStatusI18ns); } /** @@ -1583,7 +1614,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->initOrderStatusI18ns(); $this->collOrderStatusI18nsPartial = true; } - if (!$this->collOrderStatusI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collOrderStatusI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddOrderStatusI18n($l); } @@ -1601,6 +1632,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to remove. + * @return OrderStatus The current object (for fluent API support) */ public function removeOrderStatusI18n($orderStatusI18n) { @@ -1610,9 +1642,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->orderStatusI18nsScheduledForDeletion = clone $this->collOrderStatusI18ns; $this->orderStatusI18nsScheduledForDeletion->clear(); } - $this->orderStatusI18nsScheduledForDeletion[]= $orderStatusI18n; + $this->orderStatusI18nsScheduledForDeletion[]= clone $orderStatusI18n; $orderStatusI18n->setOrderStatus(null); } + + return $this; } /** @@ -1626,6 +1660,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1643,7 +1678,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collOrders) { foreach ($this->collOrders as $o) { $o->clearAllReferences($deep); @@ -1654,10 +1690,12 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collOrders instanceof PropelCollection) { @@ -1713,7 +1751,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * @return OrderStatus The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1737,7 +1775,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return OrderStatusI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collOrderStatusI18ns) { @@ -1772,7 +1810,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * @return OrderStatus The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { OrderStatusI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php index 252ef0116..976b1d0af 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php @@ -53,7 +53,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = OrderStatusI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(OrderStatusI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(OrderStatusI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(OrderStatusI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(OrderStatusI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(OrderStatusI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(OrderStatusI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent * Get the associated OrderStatus object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return OrderStatus The associated OrderStatus object. * @throws PropelException */ - public function getOrderStatus(PropelPDO $con = null) + public function getOrderStatus(PropelPDO $con = null, $doQuery = true) { - if ($this->aOrderStatus === null && ($this->id !== null)) { + if ($this->aOrderStatus === null && ($this->id !== null) && $doQuery) { $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseOrderStatusI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aOrderStatus instanceof Persistent) { + $this->aOrderStatus->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aOrderStatus = null; diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php index 1e10fa95a..2c44a0b2d 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseOrderStatusI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'order_status_i18n.ID'; + /** the column name for the id field */ + const ID = 'order_status_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'order_status_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'order_status_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'order_status_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'order_status_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'order_status_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'order_status_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'order_status_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'order_status_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'order_status_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'order_status_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseOrderStatusI18nPeer $criteria->addSelectColumn(OrderStatusI18nPeer::CHAPO); $criteria->addSelectColumn(OrderStatusI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseOrderStatusI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseOrderStatusI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderStatusI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderStatusI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseOrderStatusI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderStatusI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php index 90be26fb4..33eddef85 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseOrderStatusI18nQuery extends ModelCriteria * Returns a new OrderStatusI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderStatusI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderStatusI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderStatusI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseOrderStatusI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return OrderStatusI18n A model object, or null if the key is not found - * @throws PropelException + * @return OrderStatusI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `order_status_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `order_status_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseOrderStatusI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByOrderStatus() @@ -273,8 +274,22 @@ abstract class BaseOrderStatusI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderStatusI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderStatusI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderStatusI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseOrderStatusI18nQuery extends ModelCriteria * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderStatusI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderStatusI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderStatus($orderStatus, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php index 11ab23b9d..173f410c9 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php @@ -46,17 +46,17 @@ abstract class BaseOrderStatusPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'order_status.ID'; + /** the column name for the id field */ + const ID = 'order_status.id'; - /** the column name for the CODE field */ - const CODE = 'order_status.CODE'; + /** the column name for the code field */ + const CODE = 'order_status.code'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'order_status.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'order_status.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_status.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'order_status.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -76,7 +76,7 @@ abstract class BaseOrderStatusPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -183,10 +183,10 @@ abstract class BaseOrderStatusPeer $criteria->addSelectColumn(OrderStatusPeer::CREATED_AT); $criteria->addSelectColumn(OrderStatusPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -270,7 +270,7 @@ abstract class BaseOrderStatusPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -375,8 +375,15 @@ abstract class BaseOrderStatusPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (OrderStatusPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } OrderStatusPeer::$instances = array(); } @@ -517,7 +524,7 @@ abstract class BaseOrderStatusPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return OrderStatusPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php index 946a36d9d..d8c1f3c7f 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php @@ -48,7 +48,6 @@ use Thelia\Model\OrderStatusQuery; * @method OrderStatus findOne(PropelPDO $con = null) Return the first OrderStatus matching the query * @method OrderStatus findOneOrCreate(PropelPDO $con = null) Return the first OrderStatus matching the query, or a new OrderStatus object populated from the query conditions when no match is found * - * @method OrderStatus findOneById(int $id) Return the first OrderStatus filtered by the id column * @method OrderStatus findOneByCode(string $code) Return the first OrderStatus filtered by the code column * @method OrderStatus findOneByCreatedAt(string $created_at) Return the first OrderStatus filtered by the created_at column * @method OrderStatus findOneByUpdatedAt(string $updated_at) Return the first OrderStatus filtered by the updated_at column @@ -78,7 +77,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * Returns a new OrderStatusQuery object. * * @param string $modelAlias The alias of a model in the query - * @param OrderStatusQuery|Criteria $criteria Optional Criteria to build the query from + * @param OrderStatusQuery|Criteria $criteria Optional Criteria to build the query from * * @return OrderStatusQuery */ @@ -134,6 +133,20 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return OrderStatus A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -141,12 +154,12 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return OrderStatus A model object, or null if the key is not found - * @throws PropelException + * @return OrderStatus A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `order_status` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `order_status` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -242,7 +255,8 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -255,8 +269,22 @@ abstract class BaseOrderStatusQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderStatusPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderStatusPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(OrderStatusPeer::ID, $id, $comparison); @@ -383,8 +411,8 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @param Order|PropelObjectCollection $order the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderStatusQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderStatusQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrder($order, $comparison = null) { @@ -457,8 +485,8 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @param OrderStatusI18n|PropelObjectCollection $orderStatusI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return OrderStatusQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return OrderStatusQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByOrderStatusI18n($orderStatusI18n, $comparison = null) { @@ -617,7 +645,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @return OrderStatusQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; @@ -635,7 +663,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @return OrderStatusQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -656,7 +684,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @return OrderStatusI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php index dee173dbd..090bead7a 100644 --- a/core/lib/Thelia/Model/om/BaseProduct.php +++ b/core/lib/Thelia/Model/om/BaseProduct.php @@ -262,13 +262,19 @@ abstract class BaseProduct extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -514,22 +520,25 @@ abstract class BaseProduct extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -551,22 +560,25 @@ abstract class BaseProduct extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -598,22 +610,25 @@ abstract class BaseProduct extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -634,7 +649,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -655,7 +670,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setTaxRuleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -680,7 +695,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -701,7 +716,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setPrice($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -722,7 +737,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setPrice2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -743,7 +758,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setEcotax($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -764,7 +779,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setNewness($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -785,7 +800,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setPromo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -806,7 +821,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setStock($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -827,7 +842,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -848,7 +863,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setWeight($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -869,7 +884,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -936,7 +951,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -980,7 +995,7 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -1069,7 +1084,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 17; // 17 = ProductPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -1328,7 +1343,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collProductCategorys !== null) { foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1345,7 +1360,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collFeatureProds !== null) { foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1362,7 +1377,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collStocks !== null) { foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1380,7 +1395,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collContentAssocs !== null) { foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1398,7 +1413,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collImages !== null) { foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1416,7 +1431,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collDocuments !== null) { foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1433,7 +1448,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collAccessorysRelatedByProductId !== null) { foreach ($this->collAccessorysRelatedByProductId as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1450,7 +1465,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collAccessorysRelatedByAccessory !== null) { foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1468,7 +1483,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1485,7 +1500,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collProductI18ns !== null) { foreach ($this->collProductI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1502,7 +1517,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->collProductVersions !== null) { foreach ($this->collProductVersions as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -1535,55 +1550,55 @@ abstract class BaseProduct extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`'; + $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; } if ($this->isColumnModified(ProductPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(ProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`PRICE`'; + $modifiedColumns[':p' . $index++] = '`price`'; } if ($this->isColumnModified(ProductPeer::PRICE2)) { - $modifiedColumns[':p' . $index++] = '`PRICE2`'; + $modifiedColumns[':p' . $index++] = '`price2`'; } if ($this->isColumnModified(ProductPeer::ECOTAX)) { - $modifiedColumns[':p' . $index++] = '`ECOTAX`'; + $modifiedColumns[':p' . $index++] = '`ecotax`'; } if ($this->isColumnModified(ProductPeer::NEWNESS)) { - $modifiedColumns[':p' . $index++] = '`NEWNESS`'; + $modifiedColumns[':p' . $index++] = '`newness`'; } if ($this->isColumnModified(ProductPeer::PROMO)) { - $modifiedColumns[':p' . $index++] = '`PROMO`'; + $modifiedColumns[':p' . $index++] = '`promo`'; } if ($this->isColumnModified(ProductPeer::STOCK)) { - $modifiedColumns[':p' . $index++] = '`STOCK`'; + $modifiedColumns[':p' . $index++] = '`stock`'; } if ($this->isColumnModified(ProductPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(ProductPeer::WEIGHT)) { - $modifiedColumns[':p' . $index++] = '`WEIGHT`'; + $modifiedColumns[':p' . $index++] = '`weight`'; } if ($this->isColumnModified(ProductPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(ProductPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -1596,55 +1611,55 @@ abstract class BaseProduct extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`TAX_RULE_ID`': + case '`tax_rule_id`': $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`PRICE`': + case '`price`': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`PRICE2`': + case '`price2`': $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR); break; - case '`ECOTAX`': + case '`ecotax`': $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR); break; - case '`NEWNESS`': + case '`newness`': $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT); break; - case '`PROMO`': + case '`promo`': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; - case '`STOCK`': + case '`stock`': $stmt->bindValue($identifier, $this->stock, PDO::PARAM_INT); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`WEIGHT`': + case '`weight`': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1715,11 +1730,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -2405,12 +2420,13 @@ abstract class BaseProduct extends BaseObject implements Persistent * Get the associated TaxRule object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return TaxRule The associated TaxRule object. * @throws PropelException */ - public function getTaxRule(PropelPDO $con = null) + public function getTaxRule(PropelPDO $con = null, $doQuery = true) { - if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) { + if ($this->aTaxRule === null && ($this->tax_rule_id !== null) && $doQuery) { $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -2476,13 +2492,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addProductCategorys() */ public function clearProductCategorys() { $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized $this->collProductCategorysPartial = null; + + return $this; } /** @@ -2554,6 +2572,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductCategorysPartial = true; } + $collProductCategorys->getInternalIterator()->rewind(); return $collProductCategorys; } @@ -2581,12 +2600,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $productCategorys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) { - $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); - foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { + $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); + + foreach ($productCategorysToDelete as $productCategoryRemoved) { $productCategoryRemoved->setProduct(null); } @@ -2597,6 +2619,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductCategorys = $productCategorys; $this->collProductCategorysPartial = false; + + return $this; } /** @@ -2614,22 +2638,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collProductCategorys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProductCategorys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getProductCategorys()); - } - $query = ProductCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collProductCategorys); + + if($partial && !$criteria) { + return count($this->getProductCategorys()); + } + $query = ProductCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collProductCategorys); } /** @@ -2645,7 +2669,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initProductCategorys(); $this->collProductCategorysPartial = true; } - if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductCategory($l); } @@ -2663,6 +2687,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param ProductCategory $productCategory The productCategory object to remove. + * @return Product The current object (for fluent API support) */ public function removeProductCategory($productCategory) { @@ -2672,9 +2697,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; $this->productCategorysScheduledForDeletion->clear(); } - $this->productCategorysScheduledForDeletion[]= $productCategory; + $this->productCategorysScheduledForDeletion[]= clone $productCategory; $productCategory->setProduct(null); } + + return $this; } @@ -2708,13 +2735,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addFeatureProds() */ public function clearFeatureProds() { $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized $this->collFeatureProdsPartial = null; + + return $this; } /** @@ -2786,6 +2815,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collFeatureProdsPartial = true; } + $collFeatureProds->getInternalIterator()->rewind(); return $collFeatureProds; } @@ -2813,12 +2843,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $featureProds A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) { - $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); + $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { + $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setProduct(null); } @@ -2829,6 +2862,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collFeatureProds = $featureProds; $this->collFeatureProdsPartial = false; + + return $this; } /** @@ -2846,22 +2881,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collFeatureProds || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureProds) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collFeatureProds); + + if($partial && !$criteria) { + return count($this->getFeatureProds()); + } + $query = FeatureProdQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collFeatureProds); } /** @@ -2877,7 +2912,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initFeatureProds(); $this->collFeatureProdsPartial = true; } - if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureProd($l); } @@ -2895,6 +2930,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param FeatureProd $featureProd The featureProd object to remove. + * @return Product The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -2904,9 +2940,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; $this->featureProdsScheduledForDeletion->clear(); } - $this->featureProdsScheduledForDeletion[]= $featureProd; + $this->featureProdsScheduledForDeletion[]= clone $featureProd; $featureProd->setProduct(null); } + + return $this; } @@ -2965,13 +3003,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addStocks() */ public function clearStocks() { $this->collStocks = null; // important to set this to null since that means it is uninitialized $this->collStocksPartial = null; + + return $this; } /** @@ -3043,6 +3083,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collStocksPartial = true; } + $collStocks->getInternalIterator()->rewind(); return $collStocks; } @@ -3070,12 +3111,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $stocks A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setStocks(PropelCollection $stocks, PropelPDO $con = null) { - $this->stocksScheduledForDeletion = $this->getStocks(new Criteria(), $con)->diff($stocks); + $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - foreach ($this->stocksScheduledForDeletion as $stockRemoved) { + $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); + + foreach ($stocksToDelete as $stockRemoved) { $stockRemoved->setProduct(null); } @@ -3086,6 +3130,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collStocks = $stocks; $this->collStocksPartial = false; + + return $this; } /** @@ -3103,22 +3149,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collStocks || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collStocks) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getStocks()); - } - $query = StockQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collStocks); + + if($partial && !$criteria) { + return count($this->getStocks()); + } + $query = StockQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collStocks); } /** @@ -3134,7 +3180,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initStocks(); $this->collStocksPartial = true; } - if (!$this->collStocks->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddStock($l); } @@ -3152,6 +3198,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param Stock $stock The stock object to remove. + * @return Product The current object (for fluent API support) */ public function removeStock($stock) { @@ -3161,9 +3208,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->stocksScheduledForDeletion = clone $this->collStocks; $this->stocksScheduledForDeletion->clear(); } - $this->stocksScheduledForDeletion[]= $stock; + $this->stocksScheduledForDeletion[]= clone $stock; $stock->setProduct(null); } + + return $this; } @@ -3197,13 +3246,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addContentAssocs() */ public function clearContentAssocs() { $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized $this->collContentAssocsPartial = null; + + return $this; } /** @@ -3275,6 +3326,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collContentAssocsPartial = true; } + $collContentAssocs->getInternalIterator()->rewind(); return $collContentAssocs; } @@ -3302,12 +3354,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $contentAssocs A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) { - $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); + $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) { + $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setProduct(null); } @@ -3318,6 +3373,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collContentAssocs = $contentAssocs; $this->collContentAssocsPartial = false; + + return $this; } /** @@ -3335,22 +3392,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collContentAssocs || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collContentAssocs) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collContentAssocs); + + if($partial && !$criteria) { + return count($this->getContentAssocs()); + } + $query = ContentAssocQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collContentAssocs); } /** @@ -3366,7 +3423,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initContentAssocs(); $this->collContentAssocsPartial = true; } - if (!$this->collContentAssocs->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddContentAssoc($l); } @@ -3384,6 +3441,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return Product The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -3396,6 +3454,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->contentAssocsScheduledForDeletion[]= $contentAssoc; $contentAssoc->setProduct(null); } + + return $this; } @@ -3454,13 +3514,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addImages() */ public function clearImages() { $this->collImages = null; // important to set this to null since that means it is uninitialized $this->collImagesPartial = null; + + return $this; } /** @@ -3532,6 +3594,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collImagesPartial = true; } + $collImages->getInternalIterator()->rewind(); return $collImages; } @@ -3559,12 +3622,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $images A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setImages(PropelCollection $images, PropelPDO $con = null) { - $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); + $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - foreach ($this->imagesScheduledForDeletion as $imageRemoved) { + $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setProduct(null); } @@ -3575,6 +3641,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collImages = $images; $this->collImagesPartial = false; + + return $this; } /** @@ -3592,22 +3660,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collImages || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collImages) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collImages); + + if($partial && !$criteria) { + return count($this->getImages()); + } + $query = ImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collImages); } /** @@ -3623,7 +3691,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initImages(); $this->collImagesPartial = true; } - if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddImage($l); } @@ -3641,6 +3709,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param Image $image The image object to remove. + * @return Product The current object (for fluent API support) */ public function removeImage($image) { @@ -3653,6 +3722,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->imagesScheduledForDeletion[]= $image; $image->setProduct(null); } + + return $this; } @@ -3736,13 +3807,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addDocuments() */ public function clearDocuments() { $this->collDocuments = null; // important to set this to null since that means it is uninitialized $this->collDocumentsPartial = null; + + return $this; } /** @@ -3814,6 +3887,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collDocumentsPartial = true; } + $collDocuments->getInternalIterator()->rewind(); return $collDocuments; } @@ -3841,12 +3915,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $documents A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setDocuments(PropelCollection $documents, PropelPDO $con = null) { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setProduct(null); } @@ -3857,6 +3934,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collDocuments = $documents; $this->collDocumentsPartial = false; + + return $this; } /** @@ -3874,22 +3953,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collDocuments || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocuments) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collDocuments); + + if($partial && !$criteria) { + return count($this->getDocuments()); + } + $query = DocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collDocuments); } /** @@ -3905,7 +3984,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initDocuments(); $this->collDocumentsPartial = true; } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddDocument($l); } @@ -3923,6 +4002,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param Document $document The document object to remove. + * @return Product The current object (for fluent API support) */ public function removeDocument($document) { @@ -3935,6 +4015,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->documentsScheduledForDeletion[]= $document; $document->setProduct(null); } + + return $this; } @@ -4018,13 +4100,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addAccessorysRelatedByProductId() */ public function clearAccessorysRelatedByProductId() { $this->collAccessorysRelatedByProductId = null; // important to set this to null since that means it is uninitialized $this->collAccessorysRelatedByProductIdPartial = null; + + return $this; } /** @@ -4096,6 +4180,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collAccessorysRelatedByProductIdPartial = true; } + $collAccessorysRelatedByProductId->getInternalIterator()->rewind(); return $collAccessorysRelatedByProductId; } @@ -4123,12 +4208,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $accessorysRelatedByProductId A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setAccessorysRelatedByProductId(PropelCollection $accessorysRelatedByProductId, PropelPDO $con = null) { - $this->accessorysRelatedByProductIdScheduledForDeletion = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId); + $accessorysRelatedByProductIdToDelete = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId); - foreach ($this->accessorysRelatedByProductIdScheduledForDeletion as $accessoryRelatedByProductIdRemoved) { + $this->accessorysRelatedByProductIdScheduledForDeletion = unserialize(serialize($accessorysRelatedByProductIdToDelete)); + + foreach ($accessorysRelatedByProductIdToDelete as $accessoryRelatedByProductIdRemoved) { $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null); } @@ -4139,6 +4227,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collAccessorysRelatedByProductId = $accessorysRelatedByProductId; $this->collAccessorysRelatedByProductIdPartial = false; + + return $this; } /** @@ -4156,22 +4246,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByProductId()); - } - $query = AccessoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByProductId($this) - ->count($con); } - } else { - return count($this->collAccessorysRelatedByProductId); + + if($partial && !$criteria) { + return count($this->getAccessorysRelatedByProductId()); + } + $query = AccessoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProductRelatedByProductId($this) + ->count($con); } + + return count($this->collAccessorysRelatedByProductId); } /** @@ -4187,7 +4277,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initAccessorysRelatedByProductId(); $this->collAccessorysRelatedByProductIdPartial = true; } - if (!$this->collAccessorysRelatedByProductId->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAccessorysRelatedByProductId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAccessoryRelatedByProductId($l); } @@ -4205,6 +4295,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove. + * @return Product The current object (for fluent API support) */ public function removeAccessoryRelatedByProductId($accessoryRelatedByProductId) { @@ -4214,9 +4305,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->accessorysRelatedByProductIdScheduledForDeletion = clone $this->collAccessorysRelatedByProductId; $this->accessorysRelatedByProductIdScheduledForDeletion->clear(); } - $this->accessorysRelatedByProductIdScheduledForDeletion[]= $accessoryRelatedByProductId; + $this->accessorysRelatedByProductIdScheduledForDeletion[]= clone $accessoryRelatedByProductId; $accessoryRelatedByProductId->setProductRelatedByProductId(null); } + + return $this; } /** @@ -4225,13 +4318,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addAccessorysRelatedByAccessory() */ public function clearAccessorysRelatedByAccessory() { $this->collAccessorysRelatedByAccessory = null; // important to set this to null since that means it is uninitialized $this->collAccessorysRelatedByAccessoryPartial = null; + + return $this; } /** @@ -4303,6 +4398,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collAccessorysRelatedByAccessoryPartial = true; } + $collAccessorysRelatedByAccessory->getInternalIterator()->rewind(); return $collAccessorysRelatedByAccessory; } @@ -4330,12 +4426,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $accessorysRelatedByAccessory A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setAccessorysRelatedByAccessory(PropelCollection $accessorysRelatedByAccessory, PropelPDO $con = null) { - $this->accessorysRelatedByAccessoryScheduledForDeletion = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory); + $accessorysRelatedByAccessoryToDelete = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory); - foreach ($this->accessorysRelatedByAccessoryScheduledForDeletion as $accessoryRelatedByAccessoryRemoved) { + $this->accessorysRelatedByAccessoryScheduledForDeletion = unserialize(serialize($accessorysRelatedByAccessoryToDelete)); + + foreach ($accessorysRelatedByAccessoryToDelete as $accessoryRelatedByAccessoryRemoved) { $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null); } @@ -4346,6 +4445,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collAccessorysRelatedByAccessory = $accessorysRelatedByAccessory; $this->collAccessorysRelatedByAccessoryPartial = false; + + return $this; } /** @@ -4363,22 +4464,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByAccessory()); - } - $query = AccessoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByAccessory($this) - ->count($con); } - } else { - return count($this->collAccessorysRelatedByAccessory); + + if($partial && !$criteria) { + return count($this->getAccessorysRelatedByAccessory()); + } + $query = AccessoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProductRelatedByAccessory($this) + ->count($con); } + + return count($this->collAccessorysRelatedByAccessory); } /** @@ -4394,7 +4495,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initAccessorysRelatedByAccessory(); $this->collAccessorysRelatedByAccessoryPartial = true; } - if (!$this->collAccessorysRelatedByAccessory->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collAccessorysRelatedByAccessory->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAccessoryRelatedByAccessory($l); } @@ -4412,6 +4513,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove. + * @return Product The current object (for fluent API support) */ public function removeAccessoryRelatedByAccessory($accessoryRelatedByAccessory) { @@ -4421,9 +4523,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->accessorysRelatedByAccessoryScheduledForDeletion = clone $this->collAccessorysRelatedByAccessory; $this->accessorysRelatedByAccessoryScheduledForDeletion->clear(); } - $this->accessorysRelatedByAccessoryScheduledForDeletion[]= $accessoryRelatedByAccessory; + $this->accessorysRelatedByAccessoryScheduledForDeletion[]= clone $accessoryRelatedByAccessory; $accessoryRelatedByAccessory->setProductRelatedByAccessory(null); } + + return $this; } /** @@ -4432,13 +4536,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addRewritings() */ public function clearRewritings() { $this->collRewritings = null; // important to set this to null since that means it is uninitialized $this->collRewritingsPartial = null; + + return $this; } /** @@ -4510,6 +4616,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collRewritingsPartial = true; } + $collRewritings->getInternalIterator()->rewind(); return $collRewritings; } @@ -4537,12 +4644,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $rewritings A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) { - $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings); + $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) { + $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setProduct(null); } @@ -4553,6 +4663,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collRewritings = $rewritings; $this->collRewritingsPartial = false; + + return $this; } /** @@ -4570,22 +4682,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collRewritings || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRewritings) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collRewritings); + + if($partial && !$criteria) { + return count($this->getRewritings()); + } + $query = RewritingQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collRewritings); } /** @@ -4601,7 +4713,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initRewritings(); $this->collRewritingsPartial = true; } - if (!$this->collRewritings->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddRewriting($l); } @@ -4619,6 +4731,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param Rewriting $rewriting The rewriting object to remove. + * @return Product The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -4631,6 +4744,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->rewritingsScheduledForDeletion[]= $rewriting; $rewriting->setProduct(null); } + + return $this; } @@ -4714,13 +4829,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addProductI18ns() */ public function clearProductI18ns() { $this->collProductI18ns = null; // important to set this to null since that means it is uninitialized $this->collProductI18nsPartial = null; + + return $this; } /** @@ -4792,6 +4909,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductI18nsPartial = true; } + $collProductI18ns->getInternalIterator()->rewind(); return $collProductI18ns; } @@ -4819,12 +4937,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $productI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setProductI18ns(PropelCollection $productI18ns, PropelPDO $con = null) { - $this->productI18nsScheduledForDeletion = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns); + $productI18nsToDelete = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns); - foreach ($this->productI18nsScheduledForDeletion as $productI18nRemoved) { + $this->productI18nsScheduledForDeletion = unserialize(serialize($productI18nsToDelete)); + + foreach ($productI18nsToDelete as $productI18nRemoved) { $productI18nRemoved->setProduct(null); } @@ -4835,6 +4956,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductI18ns = $productI18ns; $this->collProductI18nsPartial = false; + + return $this; } /** @@ -4852,22 +4975,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collProductI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProductI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getProductI18ns()); - } - $query = ProductI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collProductI18ns); + + if($partial && !$criteria) { + return count($this->getProductI18ns()); + } + $query = ProductI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collProductI18ns); } /** @@ -4887,7 +5010,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initProductI18ns(); $this->collProductI18nsPartial = true; } - if (!$this->collProductI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collProductI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductI18n($l); } @@ -4905,6 +5028,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param ProductI18n $productI18n The productI18n object to remove. + * @return Product The current object (for fluent API support) */ public function removeProductI18n($productI18n) { @@ -4914,9 +5038,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->productI18nsScheduledForDeletion = clone $this->collProductI18ns; $this->productI18nsScheduledForDeletion->clear(); } - $this->productI18nsScheduledForDeletion[]= $productI18n; + $this->productI18nsScheduledForDeletion[]= clone $productI18n; $productI18n->setProduct(null); } + + return $this; } /** @@ -4925,13 +5051,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Product The current object (for fluent API support) * @see addProductVersions() */ public function clearProductVersions() { $this->collProductVersions = null; // important to set this to null since that means it is uninitialized $this->collProductVersionsPartial = null; + + return $this; } /** @@ -5003,6 +5131,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductVersionsPartial = true; } + $collProductVersions->getInternalIterator()->rewind(); return $collProductVersions; } @@ -5030,12 +5159,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param PropelCollection $productVersions A Propel collection. * @param PropelPDO $con Optional connection object + * @return Product The current object (for fluent API support) */ public function setProductVersions(PropelCollection $productVersions, PropelPDO $con = null) { - $this->productVersionsScheduledForDeletion = $this->getProductVersions(new Criteria(), $con)->diff($productVersions); + $productVersionsToDelete = $this->getProductVersions(new Criteria(), $con)->diff($productVersions); - foreach ($this->productVersionsScheduledForDeletion as $productVersionRemoved) { + $this->productVersionsScheduledForDeletion = unserialize(serialize($productVersionsToDelete)); + + foreach ($productVersionsToDelete as $productVersionRemoved) { $productVersionRemoved->setProduct(null); } @@ -5046,6 +5178,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductVersions = $productVersions; $this->collProductVersionsPartial = false; + + return $this; } /** @@ -5063,22 +5197,22 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null === $this->collProductVersions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProductVersions) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getProductVersions()); - } - $query = ProductVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); } - } else { - return count($this->collProductVersions); + + if($partial && !$criteria) { + return count($this->getProductVersions()); + } + $query = ProductVersionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); } + + return count($this->collProductVersions); } /** @@ -5094,7 +5228,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->initProductVersions(); $this->collProductVersionsPartial = true; } - if (!$this->collProductVersions->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collProductVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductVersion($l); } @@ -5112,6 +5246,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * @param ProductVersion $productVersion The productVersion object to remove. + * @return Product The current object (for fluent API support) */ public function removeProductVersion($productVersion) { @@ -5121,9 +5256,11 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->productVersionsScheduledForDeletion = clone $this->collProductVersions; $this->productVersionsScheduledForDeletion->clear(); } - $this->productVersionsScheduledForDeletion[]= $productVersion; + $this->productVersionsScheduledForDeletion[]= clone $productVersion; $productVersion->setProduct(null); } + + return $this; } /** @@ -5150,6 +5287,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -5168,7 +5306,8 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collProductCategorys) { foreach ($this->collProductCategorys as $o) { $o->clearAllReferences($deep); @@ -5224,10 +5363,15 @@ abstract class BaseProduct extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->aTaxRule instanceof Persistent) { + $this->aTaxRule->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProductCategorys instanceof PropelCollection) { @@ -5320,7 +5464,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @return Product The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -5344,7 +5488,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ProductI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductI18ns) { @@ -5379,7 +5523,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @return Product The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ProductI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseProductCategory.php b/core/lib/Thelia/Model/om/BaseProductCategory.php index 7f07dce2b..726ea6384 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategory.php +++ b/core/lib/Thelia/Model/om/BaseProductCategory.php @@ -97,6 +97,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [product_id] column value. * @@ -136,22 +142,25 @@ abstract class BaseProductCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -173,22 +182,25 @@ abstract class BaseProductCategory extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -199,7 +211,7 @@ abstract class BaseProductCategory extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -224,7 +236,7 @@ abstract class BaseProductCategory extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -330,7 +342,7 @@ abstract class BaseProductCategory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -578,16 +590,16 @@ abstract class BaseProductCategory extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(ProductCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -600,16 +612,16 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -673,11 +685,11 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1062,12 +1074,13 @@ abstract class BaseProductCategory extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1113,12 +1126,13 @@ abstract class BaseProductCategory extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1143,6 +1157,7 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1160,7 +1175,16 @@ abstract class BaseProductCategory extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php index b5b899fe9..b564bf650 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php @@ -46,17 +46,17 @@ abstract class BaseProductCategoryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'product_category.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'product_category.product_id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'product_category.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'product_category.category_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'product_category.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'product_category.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'product_category.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'product_category.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -176,10 +176,10 @@ abstract class BaseProductCategoryPeer $criteria->addSelectColumn(ProductCategoryPeer::CREATED_AT); $criteria->addSelectColumn(ProductCategoryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -263,7 +263,7 @@ abstract class BaseProductCategoryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -368,8 +368,15 @@ abstract class BaseProductCategoryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ProductCategoryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ProductCategoryPeer::$instances = array(); } @@ -1135,7 +1142,7 @@ abstract class BaseProductCategoryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ProductCategoryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php index 92dd1ebfa..30a1d64d7 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php @@ -78,7 +78,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * Returns a new ProductCategoryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ProductCategoryQuery|Criteria $criteria Optional Criteria to build the query from + * @param ProductCategoryQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProductCategoryQuery */ @@ -142,12 +142,12 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ProductCategory A model object, or null if the key is not found - * @throws PropelException + * @return ProductCategory A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `PRODUCT_ID`, `CATEGORY_ID`, `CREATED_AT`, `UPDATED_AT` FROM `product_category` WHERE `PRODUCT_ID` = :p0 AND `CATEGORY_ID` = :p1'; + $sql = 'SELECT `product_id`, `category_id`, `created_at`, `updated_at` FROM `product_category` WHERE `product_id` = :p0 AND `category_id` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -255,7 +255,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -270,8 +271,22 @@ abstract class BaseProductCategoryQuery extends ModelCriteria */ public function filterByProductId($productId = null, $comparison = null) { - if (is_array($productId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId, $comparison); @@ -284,7 +299,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -299,8 +315,22 @@ abstract class BaseProductCategoryQuery extends ModelCriteria */ public function filterByCategoryId($categoryId = null, $comparison = null) { - if (is_array($categoryId) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($categoryId)) { + $useMinMax = false; + if (isset($categoryId['min'])) { + $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryId['max'])) { + $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison); @@ -398,8 +428,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -474,8 +504,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductCategoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseProductI18n.php b/core/lib/Thelia/Model/om/BaseProductI18n.php index c65a5ab38..d88cdd9c2 100644 --- a/core/lib/Thelia/Model/om/BaseProductI18n.php +++ b/core/lib/Thelia/Model/om/BaseProductI18n.php @@ -53,7 +53,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ProductI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseProductI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ProductI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ProductI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ProductI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ProductI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ProductI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ProductI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseProductI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseProductI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseProductI18n extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->id !== null)) { + if ($this->aProduct === null && ($this->id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseProductI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseProductI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseProductI18nPeer.php b/core/lib/Thelia/Model/om/BaseProductI18nPeer.php index a06f20c28..5d16d3204 100644 --- a/core/lib/Thelia/Model/om/BaseProductI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseProductI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'product_i18n.ID'; + /** the column name for the id field */ + const ID = 'product_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'product_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'product_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'product_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'product_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'product_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'product_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'product_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'product_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'product_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'product_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseProductI18nPeer $criteria->addSelectColumn(ProductI18nPeer::CHAPO); $criteria->addSelectColumn(ProductI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseProductI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseProductI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ProductI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ProductI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseProductI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ProductI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php b/core/lib/Thelia/Model/om/BaseProductI18nQuery.php index 2f47b2172..02dc6e1fd 100644 --- a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * Returns a new ProductI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ProductI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ProductI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProductI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseProductI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ProductI18n A model object, or null if the key is not found - * @throws PropelException + * @return ProductI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `product_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `product_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseProductI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByProduct() @@ -273,8 +274,22 @@ abstract class BaseProductI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseProductI18nQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php index abb0863f3..975e77501 100644 --- a/core/lib/Thelia/Model/om/BaseProductPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductPeer.php @@ -55,56 +55,56 @@ abstract class BaseProductPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 17; - /** the column name for the ID field */ - const ID = 'product.ID'; + /** the column name for the id field */ + const ID = 'product.id'; - /** the column name for the TAX_RULE_ID field */ - const TAX_RULE_ID = 'product.TAX_RULE_ID'; + /** the column name for the tax_rule_id field */ + const TAX_RULE_ID = 'product.tax_rule_id'; - /** the column name for the REF field */ - const REF = 'product.REF'; + /** the column name for the ref field */ + const REF = 'product.ref'; - /** the column name for the PRICE field */ - const PRICE = 'product.PRICE'; + /** the column name for the price field */ + const PRICE = 'product.price'; - /** the column name for the PRICE2 field */ - const PRICE2 = 'product.PRICE2'; + /** the column name for the price2 field */ + const PRICE2 = 'product.price2'; - /** the column name for the ECOTAX field */ - const ECOTAX = 'product.ECOTAX'; + /** the column name for the ecotax field */ + const ECOTAX = 'product.ecotax'; - /** the column name for the NEWNESS field */ - const NEWNESS = 'product.NEWNESS'; + /** the column name for the newness field */ + const NEWNESS = 'product.newness'; - /** the column name for the PROMO field */ - const PROMO = 'product.PROMO'; + /** the column name for the promo field */ + const PROMO = 'product.promo'; - /** the column name for the STOCK field */ - const STOCK = 'product.STOCK'; + /** the column name for the stock field */ + const STOCK = 'product.stock'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'product.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'product.visible'; - /** the column name for the WEIGHT field */ - const WEIGHT = 'product.WEIGHT'; + /** the column name for the weight field */ + const WEIGHT = 'product.weight'; - /** the column name for the POSITION field */ - const POSITION = 'product.POSITION'; + /** the column name for the position field */ + const POSITION = 'product.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'product.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'product.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'product.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'product.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'product.VERSION'; + /** the column name for the version field */ + const VERSION = 'product.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'product.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'product.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'product.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'product.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -124,7 +124,7 @@ abstract class BaseProductPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; // versionable behavior /** @@ -251,23 +251,23 @@ abstract class BaseProductPeer $criteria->addSelectColumn(ProductPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(ProductPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TAX_RULE_ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.PRICE2'); - $criteria->addSelectColumn($alias . '.ECOTAX'); - $criteria->addSelectColumn($alias . '.NEWNESS'); - $criteria->addSelectColumn($alias . '.PROMO'); - $criteria->addSelectColumn($alias . '.STOCK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.WEIGHT'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.tax_rule_id'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.price'); + $criteria->addSelectColumn($alias . '.price2'); + $criteria->addSelectColumn($alias . '.ecotax'); + $criteria->addSelectColumn($alias . '.newness'); + $criteria->addSelectColumn($alias . '.promo'); + $criteria->addSelectColumn($alias . '.stock'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.weight'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -351,7 +351,7 @@ abstract class BaseProductPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -456,8 +456,15 @@ abstract class BaseProductPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ProductPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ProductPeer::$instances = array(); } @@ -863,7 +870,7 @@ abstract class BaseProductPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ProductPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php index 95c9db6e6..9c2049c5f 100644 --- a/core/lib/Thelia/Model/om/BaseProductQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductQuery.php @@ -123,7 +123,6 @@ use Thelia\Model\TaxRule; * @method Product findOne(PropelPDO $con = null) Return the first Product matching the query * @method Product findOneOrCreate(PropelPDO $con = null) Return the first Product matching the query, or a new Product object populated from the query conditions when no match is found * - * @method Product findOneById(int $id) Return the first Product filtered by the id column * @method Product findOneByTaxRuleId(int $tax_rule_id) Return the first Product filtered by the tax_rule_id column * @method Product findOneByRef(string $ref) Return the first Product filtered by the ref column * @method Product findOneByPrice(double $price) Return the first Product filtered by the price column @@ -179,7 +178,7 @@ abstract class BaseProductQuery extends ModelCriteria * Returns a new ProductQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ProductQuery|Criteria $criteria Optional Criteria to build the query from + * @param ProductQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProductQuery */ @@ -235,6 +234,20 @@ abstract class BaseProductQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Product A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -242,12 +255,12 @@ abstract class BaseProductQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Product A model object, or null if the key is not found - * @throws PropelException + * @return Product A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `tax_rule_id`, `ref`, `price`, `price2`, `ecotax`, `newness`, `promo`, `stock`, `visible`, `weight`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `product` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -343,7 +356,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -356,8 +370,22 @@ abstract class BaseProductQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductPeer::ID, $id, $comparison); @@ -370,7 +398,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234 * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34) - * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id >= 12 + * $query->filterByTaxRuleId(array('max' => 12)); // WHERE tax_rule_id <= 12 * * * @see filterByTaxRule() @@ -442,7 +471,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByPrice(1234); // WHERE price = 1234 * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) - * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 + * $query->filterByPrice(array('min' => 12)); // WHERE price >= 12 + * $query->filterByPrice(array('max' => 12)); // WHERE price <= 12 * * * @param mixed $price The value to use as filter. @@ -483,7 +513,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByPrice2(1234); // WHERE price2 = 1234 * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34) - * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12 + * $query->filterByPrice2(array('min' => 12)); // WHERE price2 >= 12 + * $query->filterByPrice2(array('max' => 12)); // WHERE price2 <= 12 * * * @param mixed $price2 The value to use as filter. @@ -524,7 +555,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByEcotax(1234); // WHERE ecotax = 1234 * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34) - * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12 + * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax >= 12 + * $query->filterByEcotax(array('max' => 12)); // WHERE ecotax <= 12 * * * @param mixed $ecotax The value to use as filter. @@ -565,7 +597,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByNewness(1234); // WHERE newness = 1234 * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34) - * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12 + * $query->filterByNewness(array('min' => 12)); // WHERE newness >= 12 + * $query->filterByNewness(array('max' => 12)); // WHERE newness <= 12 * * * @param mixed $newness The value to use as filter. @@ -606,7 +639,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByPromo(1234); // WHERE promo = 1234 * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34) - * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12 + * $query->filterByPromo(array('min' => 12)); // WHERE promo >= 12 + * $query->filterByPromo(array('max' => 12)); // WHERE promo <= 12 * * * @param mixed $promo The value to use as filter. @@ -647,7 +681,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByStock(1234); // WHERE stock = 1234 * $query->filterByStock(array(12, 34)); // WHERE stock IN (12, 34) - * $query->filterByStock(array('min' => 12)); // WHERE stock > 12 + * $query->filterByStock(array('min' => 12)); // WHERE stock >= 12 + * $query->filterByStock(array('max' => 12)); // WHERE stock <= 12 * * * @param mixed $stock The value to use as filter. @@ -688,7 +723,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -729,7 +765,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByWeight(1234); // WHERE weight = 1234 * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) - * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 + * $query->filterByWeight(array('min' => 12)); // WHERE weight >= 12 + * $query->filterByWeight(array('max' => 12)); // WHERE weight <= 12 * * * @param mixed $weight The value to use as filter. @@ -770,7 +807,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -897,7 +935,8 @@ abstract class BaseProductQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -1009,8 +1048,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRule($taxRule, $comparison = null) { @@ -1085,8 +1124,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductCategory($productCategory, $comparison = null) { @@ -1159,8 +1198,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFeatureProd($featureProd, $comparison = null) { @@ -1233,8 +1272,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Stock|PropelObjectCollection $stock the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByStock($stock, $comparison = null) { @@ -1307,8 +1346,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContentAssoc($contentAssoc, $comparison = null) { @@ -1381,8 +1420,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Image|PropelObjectCollection $image the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByImage($image, $comparison = null) { @@ -1455,8 +1494,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Document|PropelObjectCollection $document the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByDocument($document, $comparison = null) { @@ -1529,8 +1568,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Accessory|PropelObjectCollection $accessory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAccessoryRelatedByProductId($accessory, $comparison = null) { @@ -1603,8 +1642,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Accessory|PropelObjectCollection $accessory the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByAccessoryRelatedByAccessory($accessory, $comparison = null) { @@ -1677,8 +1716,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByRewriting($rewriting, $comparison = null) { @@ -1751,8 +1790,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param ProductI18n|PropelObjectCollection $productI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductI18n($productI18n, $comparison = null) { @@ -1825,8 +1864,8 @@ abstract class BaseProductQuery extends ModelCriteria * @param ProductVersion|PropelObjectCollection $productVersion the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProductVersion($productVersion, $comparison = null) { @@ -1985,7 +2024,7 @@ abstract class BaseProductQuery extends ModelCriteria * * @return ProductQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; @@ -2003,7 +2042,7 @@ abstract class BaseProductQuery extends ModelCriteria * * @return ProductQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -2024,7 +2063,7 @@ abstract class BaseProductQuery extends ModelCriteria * * @return ProductI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseProductVersion.php b/core/lib/Thelia/Model/om/BaseProductVersion.php index c38608f34..9f7d8f1ce 100644 --- a/core/lib/Thelia/Model/om/BaseProductVersion.php +++ b/core/lib/Thelia/Model/om/BaseProductVersion.php @@ -173,6 +173,12 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -337,22 +343,25 @@ abstract class BaseProductVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -374,22 +383,25 @@ abstract class BaseProductVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -421,22 +433,25 @@ abstract class BaseProductVersion extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->version_created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->version_created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -457,7 +472,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -482,7 +497,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setTaxRuleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -503,7 +518,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setRef($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -524,7 +539,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setPrice($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -545,7 +560,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setPrice2($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -566,7 +581,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setEcotax($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -587,7 +602,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setNewness($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -608,7 +623,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setPromo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -629,7 +644,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setStock($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -650,7 +665,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setVisible($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -671,7 +686,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setWeight($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -692,7 +707,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setPosition($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -759,7 +774,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setVersion($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -803,7 +818,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function setVersionCreatedBy($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -892,7 +907,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 17; // 17 = ProductVersionPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -1118,55 +1133,55 @@ abstract class BaseProductVersion extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ProductVersionPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`'; + $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; } if ($this->isColumnModified(ProductVersionPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`REF`'; + $modifiedColumns[':p' . $index++] = '`ref`'; } if ($this->isColumnModified(ProductVersionPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`PRICE`'; + $modifiedColumns[':p' . $index++] = '`price`'; } if ($this->isColumnModified(ProductVersionPeer::PRICE2)) { - $modifiedColumns[':p' . $index++] = '`PRICE2`'; + $modifiedColumns[':p' . $index++] = '`price2`'; } if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) { - $modifiedColumns[':p' . $index++] = '`ECOTAX`'; + $modifiedColumns[':p' . $index++] = '`ecotax`'; } if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) { - $modifiedColumns[':p' . $index++] = '`NEWNESS`'; + $modifiedColumns[':p' . $index++] = '`newness`'; } if ($this->isColumnModified(ProductVersionPeer::PROMO)) { - $modifiedColumns[':p' . $index++] = '`PROMO`'; + $modifiedColumns[':p' . $index++] = '`promo`'; } if ($this->isColumnModified(ProductVersionPeer::STOCK)) { - $modifiedColumns[':p' . $index++] = '`STOCK`'; + $modifiedColumns[':p' . $index++] = '`stock`'; } if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`VISIBLE`'; + $modifiedColumns[':p' . $index++] = '`visible`'; } if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) { - $modifiedColumns[':p' . $index++] = '`WEIGHT`'; + $modifiedColumns[':p' . $index++] = '`weight`'; } if ($this->isColumnModified(ProductVersionPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`POSITION`'; + $modifiedColumns[':p' . $index++] = '`position`'; } if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(ProductVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`VERSION`'; + $modifiedColumns[':p' . $index++] = '`version`'; } if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`version_created_at`'; } if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`'; + $modifiedColumns[':p' . $index++] = '`version_created_by`'; } $sql = sprintf( @@ -1179,55 +1194,55 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`TAX_RULE_ID`': + case '`tax_rule_id`': $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); break; - case '`REF`': + case '`ref`': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`PRICE`': + case '`price`': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`PRICE2`': + case '`price2`': $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR); break; - case '`ECOTAX`': + case '`ecotax`': $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR); break; - case '`NEWNESS`': + case '`newness`': $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT); break; - case '`PROMO`': + case '`promo`': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; - case '`STOCK`': + case '`stock`': $stmt->bindValue($identifier, $this->stock, PDO::PARAM_INT); break; - case '`VISIBLE`': + case '`visible`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`WEIGHT`': + case '`weight`': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; - case '`POSITION`': + case '`position`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; - case '`VERSION`': + case '`version`': $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT); break; - case '`VERSION_CREATED_AT`': + case '`version_created_at`': $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR); break; - case '`VERSION_CREATED_BY`': + case '`version_created_by`': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1291,11 +1306,11 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1801,12 +1816,13 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->id !== null)) { + if ($this->aProduct === null && ($this->id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1844,6 +1860,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $this->version_created_by = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1862,7 +1879,13 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseProductVersionPeer.php b/core/lib/Thelia/Model/om/BaseProductVersionPeer.php index c6da88329..cf9d5111f 100644 --- a/core/lib/Thelia/Model/om/BaseProductVersionPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductVersionPeer.php @@ -45,56 +45,56 @@ abstract class BaseProductVersionPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 17; - /** the column name for the ID field */ - const ID = 'product_version.ID'; + /** the column name for the id field */ + const ID = 'product_version.id'; - /** the column name for the TAX_RULE_ID field */ - const TAX_RULE_ID = 'product_version.TAX_RULE_ID'; + /** the column name for the tax_rule_id field */ + const TAX_RULE_ID = 'product_version.tax_rule_id'; - /** the column name for the REF field */ - const REF = 'product_version.REF'; + /** the column name for the ref field */ + const REF = 'product_version.ref'; - /** the column name for the PRICE field */ - const PRICE = 'product_version.PRICE'; + /** the column name for the price field */ + const PRICE = 'product_version.price'; - /** the column name for the PRICE2 field */ - const PRICE2 = 'product_version.PRICE2'; + /** the column name for the price2 field */ + const PRICE2 = 'product_version.price2'; - /** the column name for the ECOTAX field */ - const ECOTAX = 'product_version.ECOTAX'; + /** the column name for the ecotax field */ + const ECOTAX = 'product_version.ecotax'; - /** the column name for the NEWNESS field */ - const NEWNESS = 'product_version.NEWNESS'; + /** the column name for the newness field */ + const NEWNESS = 'product_version.newness'; - /** the column name for the PROMO field */ - const PROMO = 'product_version.PROMO'; + /** the column name for the promo field */ + const PROMO = 'product_version.promo'; - /** the column name for the STOCK field */ - const STOCK = 'product_version.STOCK'; + /** the column name for the stock field */ + const STOCK = 'product_version.stock'; - /** the column name for the VISIBLE field */ - const VISIBLE = 'product_version.VISIBLE'; + /** the column name for the visible field */ + const VISIBLE = 'product_version.visible'; - /** the column name for the WEIGHT field */ - const WEIGHT = 'product_version.WEIGHT'; + /** the column name for the weight field */ + const WEIGHT = 'product_version.weight'; - /** the column name for the POSITION field */ - const POSITION = 'product_version.POSITION'; + /** the column name for the position field */ + const POSITION = 'product_version.position'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'product_version.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'product_version.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'product_version.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'product_version.updated_at'; - /** the column name for the VERSION field */ - const VERSION = 'product_version.VERSION'; + /** the column name for the version field */ + const VERSION = 'product_version.version'; - /** the column name for the VERSION_CREATED_AT field */ - const VERSION_CREATED_AT = 'product_version.VERSION_CREATED_AT'; + /** the column name for the version_created_at field */ + const VERSION_CREATED_AT = 'product_version.version_created_at'; - /** the column name for the VERSION_CREATED_BY field */ - const VERSION_CREATED_BY = 'product_version.VERSION_CREATED_BY'; + /** the column name for the version_created_by field */ + const VERSION_CREATED_BY = 'product_version.version_created_by'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -227,23 +227,23 @@ abstract class BaseProductVersionPeer $criteria->addSelectColumn(ProductVersionPeer::VERSION_CREATED_AT); $criteria->addSelectColumn(ProductVersionPeer::VERSION_CREATED_BY); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TAX_RULE_ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.PRICE2'); - $criteria->addSelectColumn($alias . '.ECOTAX'); - $criteria->addSelectColumn($alias . '.NEWNESS'); - $criteria->addSelectColumn($alias . '.PROMO'); - $criteria->addSelectColumn($alias . '.STOCK'); - $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.WEIGHT'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT'); - $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.tax_rule_id'); + $criteria->addSelectColumn($alias . '.ref'); + $criteria->addSelectColumn($alias . '.price'); + $criteria->addSelectColumn($alias . '.price2'); + $criteria->addSelectColumn($alias . '.ecotax'); + $criteria->addSelectColumn($alias . '.newness'); + $criteria->addSelectColumn($alias . '.promo'); + $criteria->addSelectColumn($alias . '.stock'); + $criteria->addSelectColumn($alias . '.visible'); + $criteria->addSelectColumn($alias . '.weight'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.version'); + $criteria->addSelectColumn($alias . '.version_created_at'); + $criteria->addSelectColumn($alias . '.version_created_by'); } } @@ -327,7 +327,7 @@ abstract class BaseProductVersionPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -432,8 +432,15 @@ abstract class BaseProductVersionPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ProductVersionPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ProductVersionPeer::$instances = array(); } @@ -806,7 +813,7 @@ abstract class BaseProductVersionPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ProductVersionPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php b/core/lib/Thelia/Model/om/BaseProductVersionQuery.php index e92a4a85c..f4e8b5319 100644 --- a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductVersionQuery.php @@ -125,7 +125,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * Returns a new ProductVersionQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ProductVersionQuery|Criteria $criteria Optional Criteria to build the query from + * @param ProductVersionQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProductVersionQuery */ @@ -189,12 +189,12 @@ abstract class BaseProductVersionQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ProductVersion A model object, or null if the key is not found - * @throws PropelException + * @return ProductVersion A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `STOCK`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `product_version` WHERE `ID` = :p0 AND `VERSION` = :p1'; + $sql = 'SELECT `id`, `tax_rule_id`, `ref`, `price`, `price2`, `ecotax`, `newness`, `promo`, `stock`, `visible`, `weight`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `product_version` WHERE `id` = :p0 AND `version` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -302,7 +302,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByProduct() @@ -317,8 +318,22 @@ abstract class BaseProductVersionQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductVersionPeer::ID, $id, $comparison); @@ -331,7 +346,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234 * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34) - * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id >= 12 + * $query->filterByTaxRuleId(array('max' => 12)); // WHERE tax_rule_id <= 12 * * * @param mixed $taxRuleId The value to use as filter. @@ -401,7 +417,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByPrice(1234); // WHERE price = 1234 * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) - * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 + * $query->filterByPrice(array('min' => 12)); // WHERE price >= 12 + * $query->filterByPrice(array('max' => 12)); // WHERE price <= 12 * * * @param mixed $price The value to use as filter. @@ -442,7 +459,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByPrice2(1234); // WHERE price2 = 1234 * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34) - * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12 + * $query->filterByPrice2(array('min' => 12)); // WHERE price2 >= 12 + * $query->filterByPrice2(array('max' => 12)); // WHERE price2 <= 12 * * * @param mixed $price2 The value to use as filter. @@ -483,7 +501,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByEcotax(1234); // WHERE ecotax = 1234 * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34) - * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12 + * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax >= 12 + * $query->filterByEcotax(array('max' => 12)); // WHERE ecotax <= 12 * * * @param mixed $ecotax The value to use as filter. @@ -524,7 +543,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByNewness(1234); // WHERE newness = 1234 * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34) - * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12 + * $query->filterByNewness(array('min' => 12)); // WHERE newness >= 12 + * $query->filterByNewness(array('max' => 12)); // WHERE newness <= 12 * * * @param mixed $newness The value to use as filter. @@ -565,7 +585,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByPromo(1234); // WHERE promo = 1234 * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34) - * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12 + * $query->filterByPromo(array('min' => 12)); // WHERE promo >= 12 + * $query->filterByPromo(array('max' => 12)); // WHERE promo <= 12 * * * @param mixed $promo The value to use as filter. @@ -606,7 +627,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByStock(1234); // WHERE stock = 1234 * $query->filterByStock(array(12, 34)); // WHERE stock IN (12, 34) - * $query->filterByStock(array('min' => 12)); // WHERE stock > 12 + * $query->filterByStock(array('min' => 12)); // WHERE stock >= 12 + * $query->filterByStock(array('max' => 12)); // WHERE stock <= 12 * * * @param mixed $stock The value to use as filter. @@ -647,7 +669,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByVisible(1234); // WHERE visible = 1234 * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 + * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 * * * @param mixed $visible The value to use as filter. @@ -688,7 +711,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByWeight(1234); // WHERE weight = 1234 * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) - * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 + * $query->filterByWeight(array('min' => 12)); // WHERE weight >= 12 + * $query->filterByWeight(array('max' => 12)); // WHERE weight <= 12 * * * @param mixed $weight The value to use as filter. @@ -729,7 +753,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByPosition(1234); // WHERE position = 1234 * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 * * * @param mixed $position The value to use as filter. @@ -856,7 +881,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $query->filterByVersion(1234); // WHERE version = 1234 * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34) - * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 + * $query->filterByVersion(array('min' => 12)); // WHERE version >= 12 + * $query->filterByVersion(array('max' => 12)); // WHERE version <= 12 * * * @param mixed $version The value to use as filter. @@ -869,8 +895,22 @@ abstract class BaseProductVersionQuery extends ModelCriteria */ public function filterByVersion($version = null, $comparison = null) { - if (is_array($version) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($version)) { + $useMinMax = false; + if (isset($version['min'])) { + $this->addUsingAlias(ProductVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($version['max'])) { + $this->addUsingAlias(ProductVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ProductVersionPeer::VERSION, $version, $comparison); @@ -954,8 +994,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ProductVersionQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ProductVersionQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/om/BaseResource.php index 03a4945d7..d58f245f1 100644 --- a/core/lib/Thelia/Model/om/BaseResource.php +++ b/core/lib/Thelia/Model/om/BaseResource.php @@ -101,13 +101,19 @@ abstract class BaseResource extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -166,22 +172,25 @@ abstract class BaseResource extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -203,22 +212,25 @@ abstract class BaseResource extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -229,7 +241,7 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -250,7 +262,7 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -352,7 +364,7 @@ abstract class BaseResource extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = ResourcePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -565,7 +577,7 @@ abstract class BaseResource extends BaseObject implements Persistent if ($this->collGroupResources !== null) { foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -582,7 +594,7 @@ abstract class BaseResource extends BaseObject implements Persistent if ($this->collResourceI18ns !== null) { foreach ($this->collResourceI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -615,16 +627,16 @@ abstract class BaseResource extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ResourcePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ResourcePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(ResourcePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -637,16 +649,16 @@ abstract class BaseResource extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -717,11 +729,11 @@ abstract class BaseResource extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1102,13 +1114,15 @@ abstract class BaseResource extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Resource The current object (for fluent API support) * @see addGroupResources() */ public function clearGroupResources() { $this->collGroupResources = null; // important to set this to null since that means it is uninitialized $this->collGroupResourcesPartial = null; + + return $this; } /** @@ -1180,6 +1194,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->collGroupResourcesPartial = true; } + $collGroupResources->getInternalIterator()->rewind(); return $collGroupResources; } @@ -1207,12 +1222,15 @@ abstract class BaseResource extends BaseObject implements Persistent * * @param PropelCollection $groupResources A Propel collection. * @param PropelPDO $con Optional connection object + * @return Resource The current object (for fluent API support) */ public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) { - $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); + $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) { + $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); + + foreach ($groupResourcesToDelete as $groupResourceRemoved) { $groupResourceRemoved->setResource(null); } @@ -1223,6 +1241,8 @@ abstract class BaseResource extends BaseObject implements Persistent $this->collGroupResources = $groupResources; $this->collGroupResourcesPartial = false; + + return $this; } /** @@ -1240,22 +1260,22 @@ abstract class BaseResource extends BaseObject implements Persistent if (null === $this->collGroupResources || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroupResources) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getGroupResources()); - } - $query = GroupResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); } - } else { - return count($this->collGroupResources); + + if($partial && !$criteria) { + return count($this->getGroupResources()); + } + $query = GroupResourceQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByResource($this) + ->count($con); } + + return count($this->collGroupResources); } /** @@ -1271,7 +1291,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->initGroupResources(); $this->collGroupResourcesPartial = true; } - if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddGroupResource($l); } @@ -1289,6 +1309,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * @param GroupResource $groupResource The groupResource object to remove. + * @return Resource The current object (for fluent API support) */ public function removeGroupResource($groupResource) { @@ -1298,9 +1319,11 @@ abstract class BaseResource extends BaseObject implements Persistent $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; $this->groupResourcesScheduledForDeletion->clear(); } - $this->groupResourcesScheduledForDeletion[]= $groupResource; + $this->groupResourcesScheduledForDeletion[]= clone $groupResource; $groupResource->setResource(null); } + + return $this; } @@ -1334,13 +1357,15 @@ abstract class BaseResource extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Resource The current object (for fluent API support) * @see addResourceI18ns() */ public function clearResourceI18ns() { $this->collResourceI18ns = null; // important to set this to null since that means it is uninitialized $this->collResourceI18nsPartial = null; + + return $this; } /** @@ -1412,6 +1437,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->collResourceI18nsPartial = true; } + $collResourceI18ns->getInternalIterator()->rewind(); return $collResourceI18ns; } @@ -1439,12 +1465,15 @@ abstract class BaseResource extends BaseObject implements Persistent * * @param PropelCollection $resourceI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Resource The current object (for fluent API support) */ public function setResourceI18ns(PropelCollection $resourceI18ns, PropelPDO $con = null) { - $this->resourceI18nsScheduledForDeletion = $this->getResourceI18ns(new Criteria(), $con)->diff($resourceI18ns); + $resourceI18nsToDelete = $this->getResourceI18ns(new Criteria(), $con)->diff($resourceI18ns); - foreach ($this->resourceI18nsScheduledForDeletion as $resourceI18nRemoved) { + $this->resourceI18nsScheduledForDeletion = unserialize(serialize($resourceI18nsToDelete)); + + foreach ($resourceI18nsToDelete as $resourceI18nRemoved) { $resourceI18nRemoved->setResource(null); } @@ -1455,6 +1484,8 @@ abstract class BaseResource extends BaseObject implements Persistent $this->collResourceI18ns = $resourceI18ns; $this->collResourceI18nsPartial = false; + + return $this; } /** @@ -1472,22 +1503,22 @@ abstract class BaseResource extends BaseObject implements Persistent if (null === $this->collResourceI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collResourceI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getResourceI18ns()); - } - $query = ResourceI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); } - } else { - return count($this->collResourceI18ns); + + if($partial && !$criteria) { + return count($this->getResourceI18ns()); + } + $query = ResourceI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByResource($this) + ->count($con); } + + return count($this->collResourceI18ns); } /** @@ -1507,7 +1538,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->initResourceI18ns(); $this->collResourceI18nsPartial = true; } - if (!$this->collResourceI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collResourceI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddResourceI18n($l); } @@ -1525,6 +1556,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * @param ResourceI18n $resourceI18n The resourceI18n object to remove. + * @return Resource The current object (for fluent API support) */ public function removeResourceI18n($resourceI18n) { @@ -1534,9 +1566,11 @@ abstract class BaseResource extends BaseObject implements Persistent $this->resourceI18nsScheduledForDeletion = clone $this->collResourceI18ns; $this->resourceI18nsScheduledForDeletion->clear(); } - $this->resourceI18nsScheduledForDeletion[]= $resourceI18n; + $this->resourceI18nsScheduledForDeletion[]= clone $resourceI18n; $resourceI18n->setResource(null); } + + return $this; } /** @@ -1550,6 +1584,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1567,7 +1602,8 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collGroupResources) { foreach ($this->collGroupResources as $o) { $o->clearAllReferences($deep); @@ -1578,10 +1614,12 @@ abstract class BaseResource extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collGroupResources instanceof PropelCollection) { @@ -1637,7 +1675,7 @@ abstract class BaseResource extends BaseObject implements Persistent * * @return Resource The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1661,7 +1699,7 @@ abstract class BaseResource extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return ResourceI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collResourceI18ns) { @@ -1696,7 +1734,7 @@ abstract class BaseResource extends BaseObject implements Persistent * * @return Resource The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { ResourceI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseResourceI18n.php b/core/lib/Thelia/Model/om/BaseResourceI18n.php index f08f576d4..74506641d 100644 --- a/core/lib/Thelia/Model/om/BaseResourceI18n.php +++ b/core/lib/Thelia/Model/om/BaseResourceI18n.php @@ -53,7 +53,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -101,6 +101,12 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -109,7 +115,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -190,7 +196,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -215,7 +221,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -236,7 +242,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -257,7 +263,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -278,7 +284,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setChapo($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -299,7 +305,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function setPostscriptum($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -322,7 +328,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -361,7 +367,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = ResourceI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -587,22 +593,22 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ResourceI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(ResourceI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(ResourceI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(ResourceI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(ResourceI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`CHAPO`'; + $modifiedColumns[':p' . $index++] = '`chapo`'; } if ($this->isColumnModified(ResourceI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`POSTSCRIPTUM`'; + $modifiedColumns[':p' . $index++] = '`postscriptum`'; } $sql = sprintf( @@ -615,22 +621,22 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CHAPO`': + case '`chapo`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`POSTSCRIPTUM`': + case '`postscriptum`': $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; } @@ -694,11 +700,11 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1094,12 +1100,13 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent * Get the associated Resource object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Resource The associated Resource object. * @throws PropelException */ - public function getResource(PropelPDO $con = null) + public function getResource(PropelPDO $con = null, $doQuery = true) { - if ($this->aResource === null && ($this->id !== null)) { + if ($this->aResource === null && ($this->id !== null) && $doQuery) { $this->aResource = ResourceQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1126,6 +1133,7 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent $this->postscriptum = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1144,7 +1152,13 @@ abstract class BaseResourceI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aResource instanceof Persistent) { + $this->aResource->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aResource = null; diff --git a/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php b/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php index f316e8a82..4baa86d5d 100644 --- a/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php @@ -45,23 +45,23 @@ abstract class BaseResourceI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'resource_i18n.ID'; + /** the column name for the id field */ + const ID = 'resource_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'resource_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'resource_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'resource_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'resource_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'resource_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'resource_i18n.description'; - /** the column name for the CHAPO field */ - const CHAPO = 'resource_i18n.CHAPO'; + /** the column name for the chapo field */ + const CHAPO = 'resource_i18n.chapo'; - /** the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'resource_i18n.POSTSCRIPTUM'; + /** the column name for the postscriptum field */ + const POSTSCRIPTUM = 'resource_i18n.postscriptum'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -183,12 +183,12 @@ abstract class BaseResourceI18nPeer $criteria->addSelectColumn(ResourceI18nPeer::CHAPO); $criteria->addSelectColumn(ResourceI18nPeer::POSTSCRIPTUM); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.chapo'); + $criteria->addSelectColumn($alias . '.postscriptum'); } } @@ -272,7 +272,7 @@ abstract class BaseResourceI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -377,8 +377,15 @@ abstract class BaseResourceI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ResourceI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ResourceI18nPeer::$instances = array(); } @@ -751,7 +758,7 @@ abstract class BaseResourceI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ResourceI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php b/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php index 07898fa19..e37525132 100644 --- a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php @@ -81,7 +81,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * Returns a new ResourceI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ResourceI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param ResourceI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return ResourceI18nQuery */ @@ -145,12 +145,12 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return ResourceI18n A model object, or null if the key is not found - * @throws PropelException + * @return ResourceI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM` FROM `resource_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `resource_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -258,7 +258,8 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByResource() @@ -273,8 +274,22 @@ abstract class BaseResourceI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ResourceI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ResourceI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ResourceI18nPeer::ID, $id, $comparison); @@ -431,8 +446,8 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ResourceI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ResourceI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByResource($resource, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseResourcePeer.php b/core/lib/Thelia/Model/om/BaseResourcePeer.php index cfe59b459..5e50dc19f 100644 --- a/core/lib/Thelia/Model/om/BaseResourcePeer.php +++ b/core/lib/Thelia/Model/om/BaseResourcePeer.php @@ -46,17 +46,17 @@ abstract class BaseResourcePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'resource.ID'; + /** the column name for the id field */ + const ID = 'resource.id'; - /** the column name for the CODE field */ - const CODE = 'resource.CODE'; + /** the column name for the code field */ + const CODE = 'resource.code'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'resource.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'resource.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'resource.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'resource.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -76,7 +76,7 @@ abstract class BaseResourcePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -183,10 +183,10 @@ abstract class BaseResourcePeer $criteria->addSelectColumn(ResourcePeer::CREATED_AT); $criteria->addSelectColumn(ResourcePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -270,7 +270,7 @@ abstract class BaseResourcePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -375,8 +375,15 @@ abstract class BaseResourcePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (ResourcePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } ResourcePeer::$instances = array(); } @@ -517,7 +524,7 @@ abstract class BaseResourcePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return ResourcePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/om/BaseResourceQuery.php index 7792a1462..33bc2520a 100644 --- a/core/lib/Thelia/Model/om/BaseResourceQuery.php +++ b/core/lib/Thelia/Model/om/BaseResourceQuery.php @@ -48,7 +48,6 @@ use Thelia\Model\ResourceQuery; * @method Resource findOne(PropelPDO $con = null) Return the first Resource matching the query * @method Resource findOneOrCreate(PropelPDO $con = null) Return the first Resource matching the query, or a new Resource object populated from the query conditions when no match is found * - * @method Resource findOneById(int $id) Return the first Resource filtered by the id column * @method Resource findOneByCode(string $code) Return the first Resource filtered by the code column * @method Resource findOneByCreatedAt(string $created_at) Return the first Resource filtered by the created_at column * @method Resource findOneByUpdatedAt(string $updated_at) Return the first Resource filtered by the updated_at column @@ -78,7 +77,7 @@ abstract class BaseResourceQuery extends ModelCriteria * Returns a new ResourceQuery object. * * @param string $modelAlias The alias of a model in the query - * @param ResourceQuery|Criteria $criteria Optional Criteria to build the query from + * @param ResourceQuery|Criteria $criteria Optional Criteria to build the query from * * @return ResourceQuery */ @@ -134,6 +133,20 @@ abstract class BaseResourceQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Resource A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -141,12 +154,12 @@ abstract class BaseResourceQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Resource A model object, or null if the key is not found - * @throws PropelException + * @return Resource A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `CREATED_AT`, `UPDATED_AT` FROM `resource` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `resource` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -242,7 +255,8 @@ abstract class BaseResourceQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -255,8 +269,22 @@ abstract class BaseResourceQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(ResourcePeer::ID, $id, $comparison); @@ -383,8 +411,8 @@ abstract class BaseResourceQuery extends ModelCriteria * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ResourceQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByGroupResource($groupResource, $comparison = null) { @@ -457,8 +485,8 @@ abstract class BaseResourceQuery extends ModelCriteria * @param ResourceI18n|PropelObjectCollection $resourceI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return ResourceQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByResourceI18n($resourceI18n, $comparison = null) { @@ -617,7 +645,7 @@ abstract class BaseResourceQuery extends ModelCriteria * * @return ResourceQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; @@ -635,7 +663,7 @@ abstract class BaseResourceQuery extends ModelCriteria * * @return ResourceQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -656,7 +684,7 @@ abstract class BaseResourceQuery extends ModelCriteria * * @return ResourceI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/om/BaseRewriting.php index 109a395db..4cfcdb7f7 100644 --- a/core/lib/Thelia/Model/om/BaseRewriting.php +++ b/core/lib/Thelia/Model/om/BaseRewriting.php @@ -135,6 +135,12 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -214,22 +220,25 @@ abstract class BaseRewriting extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -251,22 +260,25 @@ abstract class BaseRewriting extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -277,7 +289,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -298,7 +310,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setUrl($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -319,7 +331,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -344,7 +356,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setCategoryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -369,7 +381,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setFolderId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -394,7 +406,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function setContentId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -504,7 +516,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 8; // 8 = RewritingPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -774,28 +786,28 @@ abstract class BaseRewriting extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(RewritingPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(RewritingPeer::URL)) { - $modifiedColumns[':p' . $index++] = '`URL`'; + $modifiedColumns[':p' . $index++] = '`url`'; } if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; + $modifiedColumns[':p' . $index++] = '`category_id`'; } if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`FOLDER_ID`'; + $modifiedColumns[':p' . $index++] = '`folder_id`'; } if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`CONTENT_ID`'; + $modifiedColumns[':p' . $index++] = '`content_id`'; } if ($this->isColumnModified(RewritingPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -808,28 +820,28 @@ abstract class BaseRewriting extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`URL`': + case '`url`': $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`CATEGORY_ID`': + case '`category_id`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`FOLDER_ID`': + case '`folder_id`': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`CONTENT_ID`': + case '`content_id`': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -893,11 +905,11 @@ abstract class BaseRewriting extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1333,12 +1345,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1384,12 +1397,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent * Get the associated Category object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Category The associated Category object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null) + public function getCategory(PropelPDO $con = null, $doQuery = true) { - if ($this->aCategory === null && ($this->category_id !== null)) { + if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1435,12 +1449,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent * Get the associated Folder object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Folder The associated Folder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null) + public function getFolder(PropelPDO $con = null, $doQuery = true) { - if ($this->aFolder === null && ($this->folder_id !== null)) { + if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1486,12 +1501,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent * Get the associated Content object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Content The associated Content object. * @throws PropelException */ - public function getContent(PropelPDO $con = null) + public function getContent(PropelPDO $con = null, $doQuery = true) { - if ($this->aContent === null && ($this->content_id !== null)) { + if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1520,6 +1536,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1537,7 +1554,22 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + if ($this->aCategory instanceof Persistent) { + $this->aCategory->clearAllReferences($deep); + } + if ($this->aFolder instanceof Persistent) { + $this->aFolder->clearAllReferences($deep); + } + if ($this->aContent instanceof Persistent) { + $this->aContent->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; diff --git a/core/lib/Thelia/Model/om/BaseRewritingPeer.php b/core/lib/Thelia/Model/om/BaseRewritingPeer.php index c935e9c26..1a3558ab0 100644 --- a/core/lib/Thelia/Model/om/BaseRewritingPeer.php +++ b/core/lib/Thelia/Model/om/BaseRewritingPeer.php @@ -48,29 +48,29 @@ abstract class BaseRewritingPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 8; - /** the column name for the ID field */ - const ID = 'rewriting.ID'; + /** the column name for the id field */ + const ID = 'rewriting.id'; - /** the column name for the URL field */ - const URL = 'rewriting.URL'; + /** the column name for the url field */ + const URL = 'rewriting.url'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'rewriting.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'rewriting.product_id'; - /** the column name for the CATEGORY_ID field */ - const CATEGORY_ID = 'rewriting.CATEGORY_ID'; + /** the column name for the category_id field */ + const CATEGORY_ID = 'rewriting.category_id'; - /** the column name for the FOLDER_ID field */ - const FOLDER_ID = 'rewriting.FOLDER_ID'; + /** the column name for the folder_id field */ + const FOLDER_ID = 'rewriting.folder_id'; - /** the column name for the CONTENT_ID field */ - const CONTENT_ID = 'rewriting.CONTENT_ID'; + /** the column name for the content_id field */ + const CONTENT_ID = 'rewriting.content_id'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'rewriting.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'rewriting.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'rewriting.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'rewriting.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -194,14 +194,14 @@ abstract class BaseRewritingPeer $criteria->addSelectColumn(RewritingPeer::CREATED_AT); $criteria->addSelectColumn(RewritingPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.url'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.category_id'); + $criteria->addSelectColumn($alias . '.folder_id'); + $criteria->addSelectColumn($alias . '.content_id'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -285,7 +285,7 @@ abstract class BaseRewritingPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -390,8 +390,15 @@ abstract class BaseRewritingPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (RewritingPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } RewritingPeer::$instances = array(); } @@ -1901,7 +1908,7 @@ abstract class BaseRewritingPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return RewritingPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/om/BaseRewritingQuery.php index d3e2b47c7..2598ce1f4 100644 --- a/core/lib/Thelia/Model/om/BaseRewritingQuery.php +++ b/core/lib/Thelia/Model/om/BaseRewritingQuery.php @@ -66,7 +66,6 @@ use Thelia\Model\RewritingQuery; * @method Rewriting findOne(PropelPDO $con = null) Return the first Rewriting matching the query * @method Rewriting findOneOrCreate(PropelPDO $con = null) Return the first Rewriting matching the query, or a new Rewriting object populated from the query conditions when no match is found * - * @method Rewriting findOneById(int $id) Return the first Rewriting filtered by the id column * @method Rewriting findOneByUrl(string $url) Return the first Rewriting filtered by the url column * @method Rewriting findOneByProductId(int $product_id) Return the first Rewriting filtered by the product_id column * @method Rewriting findOneByCategoryId(int $category_id) Return the first Rewriting filtered by the category_id column @@ -104,7 +103,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * Returns a new RewritingQuery object. * * @param string $modelAlias The alias of a model in the query - * @param RewritingQuery|Criteria $criteria Optional Criteria to build the query from + * @param RewritingQuery|Criteria $criteria Optional Criteria to build the query from * * @return RewritingQuery */ @@ -160,6 +159,20 @@ abstract class BaseRewritingQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Rewriting A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -167,12 +180,12 @@ abstract class BaseRewritingQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Rewriting A model object, or null if the key is not found - * @throws PropelException + * @return Rewriting A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `URL`, `PRODUCT_ID`, `CATEGORY_ID`, `FOLDER_ID`, `CONTENT_ID`, `CREATED_AT`, `UPDATED_AT` FROM `rewriting` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `url`, `product_id`, `category_id`, `folder_id`, `content_id`, `created_at`, `updated_at` FROM `rewriting` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -268,7 +281,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -281,8 +295,22 @@ abstract class BaseRewritingQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(RewritingPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(RewritingPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(RewritingPeer::ID, $id, $comparison); @@ -324,7 +352,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -367,7 +396,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $query->filterByCategoryId(1234); // WHERE category_id = 1234 * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 + * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 * * * @see filterByCategory() @@ -410,7 +440,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $query->filterByFolderId(1234); // WHERE folder_id = 1234 * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 + * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 * * * @see filterByFolder() @@ -453,7 +484,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $query->filterByContentId(1234); // WHERE content_id = 1234 * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 + * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 * * * @see filterByContent() @@ -581,8 +613,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return RewritingQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -657,8 +689,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * @param Category|PropelObjectCollection $category The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return RewritingQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCategory($category, $comparison = null) { @@ -733,8 +765,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return RewritingQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByFolder($folder, $comparison = null) { @@ -809,8 +841,8 @@ abstract class BaseRewritingQuery extends ModelCriteria * @param Content|PropelObjectCollection $content The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return RewritingQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByContent($content, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseStock.php b/core/lib/Thelia/Model/om/BaseStock.php index 70aeb15c5..f6f4458c9 100644 --- a/core/lib/Thelia/Model/om/BaseStock.php +++ b/core/lib/Thelia/Model/om/BaseStock.php @@ -115,6 +115,12 @@ abstract class BaseStock extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -184,22 +190,25 @@ abstract class BaseStock extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -221,22 +230,25 @@ abstract class BaseStock extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -247,7 +259,7 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -268,7 +280,7 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function setCombinationId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -293,7 +305,7 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function setProductId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -318,7 +330,7 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function setIncrease($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -339,7 +351,7 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function setValue($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -444,7 +456,7 @@ abstract class BaseStock extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = StockPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -696,25 +708,25 @@ abstract class BaseStock extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(StockPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(StockPeer::COMBINATION_ID)) { - $modifiedColumns[':p' . $index++] = '`COMBINATION_ID`'; + $modifiedColumns[':p' . $index++] = '`combination_id`'; } if ($this->isColumnModified(StockPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`PRODUCT_ID`'; + $modifiedColumns[':p' . $index++] = '`product_id`'; } if ($this->isColumnModified(StockPeer::INCREASE)) { - $modifiedColumns[':p' . $index++] = '`INCREASE`'; + $modifiedColumns[':p' . $index++] = '`increase`'; } if ($this->isColumnModified(StockPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`VALUE`'; + $modifiedColumns[':p' . $index++] = '`value`'; } if ($this->isColumnModified(StockPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(StockPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -727,25 +739,25 @@ abstract class BaseStock extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`COMBINATION_ID`': + case '`combination_id`': $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT); break; - case '`PRODUCT_ID`': + case '`product_id`': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`INCREASE`': + case '`increase`': $stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR); break; - case '`VALUE`': + case '`value`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -816,11 +828,11 @@ abstract class BaseStock extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1228,12 +1240,13 @@ abstract class BaseStock extends BaseObject implements Persistent * Get the associated Combination object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Combination The associated Combination object. * @throws PropelException */ - public function getCombination(PropelPDO $con = null) + public function getCombination(PropelPDO $con = null, $doQuery = true) { - if ($this->aCombination === null && ($this->combination_id !== null)) { + if ($this->aCombination === null && ($this->combination_id !== null) && $doQuery) { $this->aCombination = CombinationQuery::create()->findPk($this->combination_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1279,12 +1292,13 @@ abstract class BaseStock extends BaseObject implements Persistent * Get the associated Product object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Product The associated Product object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null, $doQuery = true) { - if ($this->aProduct === null && ($this->product_id !== null)) { + if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1312,6 +1326,7 @@ abstract class BaseStock extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1329,7 +1344,16 @@ abstract class BaseStock extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCombination instanceof Persistent) { + $this->aCombination->clearAllReferences($deep); + } + if ($this->aProduct instanceof Persistent) { + $this->aProduct->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aCombination = null; diff --git a/core/lib/Thelia/Model/om/BaseStockPeer.php b/core/lib/Thelia/Model/om/BaseStockPeer.php index c8fcb2e8f..8a97eeab6 100644 --- a/core/lib/Thelia/Model/om/BaseStockPeer.php +++ b/core/lib/Thelia/Model/om/BaseStockPeer.php @@ -46,26 +46,26 @@ abstract class BaseStockPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'stock.ID'; + /** the column name for the id field */ + const ID = 'stock.id'; - /** the column name for the COMBINATION_ID field */ - const COMBINATION_ID = 'stock.COMBINATION_ID'; + /** the column name for the combination_id field */ + const COMBINATION_ID = 'stock.combination_id'; - /** the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'stock.PRODUCT_ID'; + /** the column name for the product_id field */ + const PRODUCT_ID = 'stock.product_id'; - /** the column name for the INCREASE field */ - const INCREASE = 'stock.INCREASE'; + /** the column name for the increase field */ + const INCREASE = 'stock.increase'; - /** the column name for the VALUE field */ - const VALUE = 'stock.VALUE'; + /** the column name for the value field */ + const VALUE = 'stock.value'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'stock.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'stock.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'stock.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'stock.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -188,13 +188,13 @@ abstract class BaseStockPeer $criteria->addSelectColumn(StockPeer::CREATED_AT); $criteria->addSelectColumn(StockPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.COMBINATION_ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.INCREASE'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.combination_id'); + $criteria->addSelectColumn($alias . '.product_id'); + $criteria->addSelectColumn($alias . '.increase'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -278,7 +278,7 @@ abstract class BaseStockPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -383,8 +383,15 @@ abstract class BaseStockPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (StockPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } StockPeer::$instances = array(); } @@ -1150,7 +1157,7 @@ abstract class BaseStockPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return StockPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/om/BaseStockQuery.php index 6cbbd1b1e..792084e78 100644 --- a/core/lib/Thelia/Model/om/BaseStockQuery.php +++ b/core/lib/Thelia/Model/om/BaseStockQuery.php @@ -54,7 +54,6 @@ use Thelia\Model\StockQuery; * @method Stock findOne(PropelPDO $con = null) Return the first Stock matching the query * @method Stock findOneOrCreate(PropelPDO $con = null) Return the first Stock matching the query, or a new Stock object populated from the query conditions when no match is found * - * @method Stock findOneById(int $id) Return the first Stock filtered by the id column * @method Stock findOneByCombinationId(int $combination_id) Return the first Stock filtered by the combination_id column * @method Stock findOneByProductId(int $product_id) Return the first Stock filtered by the product_id column * @method Stock findOneByIncrease(double $increase) Return the first Stock filtered by the increase column @@ -90,7 +89,7 @@ abstract class BaseStockQuery extends ModelCriteria * Returns a new StockQuery object. * * @param string $modelAlias The alias of a model in the query - * @param StockQuery|Criteria $criteria Optional Criteria to build the query from + * @param StockQuery|Criteria $criteria Optional Criteria to build the query from * * @return StockQuery */ @@ -146,6 +145,20 @@ abstract class BaseStockQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Stock A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -153,12 +166,12 @@ abstract class BaseStockQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Stock A model object, or null if the key is not found - * @throws PropelException + * @return Stock A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `COMBINATION_ID`, `PRODUCT_ID`, `INCREASE`, `VALUE`, `CREATED_AT`, `UPDATED_AT` FROM `stock` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `combination_id`, `product_id`, `increase`, `value`, `created_at`, `updated_at` FROM `stock` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -254,7 +267,8 @@ abstract class BaseStockQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -267,8 +281,22 @@ abstract class BaseStockQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(StockPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(StockPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(StockPeer::ID, $id, $comparison); @@ -281,7 +309,8 @@ abstract class BaseStockQuery extends ModelCriteria * * $query->filterByCombinationId(1234); // WHERE combination_id = 1234 * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34) - * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12 + * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id >= 12 + * $query->filterByCombinationId(array('max' => 12)); // WHERE combination_id <= 12 * * * @see filterByCombination() @@ -324,7 +353,8 @@ abstract class BaseStockQuery extends ModelCriteria * * $query->filterByProductId(1234); // WHERE product_id = 1234 * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 + * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 * * * @see filterByProduct() @@ -367,7 +397,8 @@ abstract class BaseStockQuery extends ModelCriteria * * $query->filterByIncrease(1234); // WHERE increase = 1234 * $query->filterByIncrease(array(12, 34)); // WHERE increase IN (12, 34) - * $query->filterByIncrease(array('min' => 12)); // WHERE increase > 12 + * $query->filterByIncrease(array('min' => 12)); // WHERE increase >= 12 + * $query->filterByIncrease(array('max' => 12)); // WHERE increase <= 12 * * * @param mixed $increase The value to use as filter. @@ -408,7 +439,8 @@ abstract class BaseStockQuery extends ModelCriteria * * $query->filterByValue(1234); // WHERE value = 1234 * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 + * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 * * * @param mixed $value The value to use as filter. @@ -534,8 +566,8 @@ abstract class BaseStockQuery extends ModelCriteria * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return StockQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return StockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCombination($combination, $comparison = null) { @@ -610,8 +642,8 @@ abstract class BaseStockQuery extends ModelCriteria * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return StockQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return StockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseTax.php b/core/lib/Thelia/Model/om/BaseTax.php index e98a029ff..9d7ad3c80 100644 --- a/core/lib/Thelia/Model/om/BaseTax.php +++ b/core/lib/Thelia/Model/om/BaseTax.php @@ -101,13 +101,19 @@ abstract class BaseTax extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -166,22 +172,25 @@ abstract class BaseTax extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -203,22 +212,25 @@ abstract class BaseTax extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -229,7 +241,7 @@ abstract class BaseTax extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -250,7 +262,7 @@ abstract class BaseTax extends BaseObject implements Persistent */ public function setRate($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (double) $v; } @@ -352,7 +364,7 @@ abstract class BaseTax extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = TaxPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -566,7 +578,7 @@ abstract class BaseTax extends BaseObject implements Persistent if ($this->collTaxRuleCountrys !== null) { foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -583,7 +595,7 @@ abstract class BaseTax extends BaseObject implements Persistent if ($this->collTaxI18ns !== null) { foreach ($this->collTaxI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -616,16 +628,16 @@ abstract class BaseTax extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TaxPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(TaxPeer::RATE)) { - $modifiedColumns[':p' . $index++] = '`RATE`'; + $modifiedColumns[':p' . $index++] = '`rate`'; } if ($this->isColumnModified(TaxPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(TaxPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -638,16 +650,16 @@ abstract class BaseTax extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`RATE`': + case '`rate`': $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -718,11 +730,11 @@ abstract class BaseTax extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1103,13 +1115,15 @@ abstract class BaseTax extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Tax The current object (for fluent API support) * @see addTaxRuleCountrys() */ public function clearTaxRuleCountrys() { $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized $this->collTaxRuleCountrysPartial = null; + + return $this; } /** @@ -1181,6 +1195,7 @@ abstract class BaseTax extends BaseObject implements Persistent $this->collTaxRuleCountrysPartial = true; } + $collTaxRuleCountrys->getInternalIterator()->rewind(); return $collTaxRuleCountrys; } @@ -1208,12 +1223,15 @@ abstract class BaseTax extends BaseObject implements Persistent * * @param PropelCollection $taxRuleCountrys A Propel collection. * @param PropelPDO $con Optional connection object + * @return Tax The current object (for fluent API support) */ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) { - $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); + $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) { + $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); + + foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { $taxRuleCountryRemoved->setTax(null); } @@ -1224,6 +1242,8 @@ abstract class BaseTax extends BaseObject implements Persistent $this->collTaxRuleCountrys = $taxRuleCountrys; $this->collTaxRuleCountrysPartial = false; + + return $this; } /** @@ -1241,22 +1261,22 @@ abstract class BaseTax extends BaseObject implements Persistent if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTaxRuleCountrys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTax($this) - ->count($con); } - } else { - return count($this->collTaxRuleCountrys); + + if($partial && !$criteria) { + return count($this->getTaxRuleCountrys()); + } + $query = TaxRuleCountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTax($this) + ->count($con); } + + return count($this->collTaxRuleCountrys); } /** @@ -1272,7 +1292,7 @@ abstract class BaseTax extends BaseObject implements Persistent $this->initTaxRuleCountrys(); $this->collTaxRuleCountrysPartial = true; } - if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleCountry($l); } @@ -1290,6 +1310,7 @@ abstract class BaseTax extends BaseObject implements Persistent /** * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return Tax The current object (for fluent API support) */ public function removeTaxRuleCountry($taxRuleCountry) { @@ -1302,6 +1323,8 @@ abstract class BaseTax extends BaseObject implements Persistent $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; $taxRuleCountry->setTax(null); } + + return $this; } @@ -1360,13 +1383,15 @@ abstract class BaseTax extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return Tax The current object (for fluent API support) * @see addTaxI18ns() */ public function clearTaxI18ns() { $this->collTaxI18ns = null; // important to set this to null since that means it is uninitialized $this->collTaxI18nsPartial = null; + + return $this; } /** @@ -1438,6 +1463,7 @@ abstract class BaseTax extends BaseObject implements Persistent $this->collTaxI18nsPartial = true; } + $collTaxI18ns->getInternalIterator()->rewind(); return $collTaxI18ns; } @@ -1465,12 +1491,15 @@ abstract class BaseTax extends BaseObject implements Persistent * * @param PropelCollection $taxI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return Tax The current object (for fluent API support) */ public function setTaxI18ns(PropelCollection $taxI18ns, PropelPDO $con = null) { - $this->taxI18nsScheduledForDeletion = $this->getTaxI18ns(new Criteria(), $con)->diff($taxI18ns); + $taxI18nsToDelete = $this->getTaxI18ns(new Criteria(), $con)->diff($taxI18ns); - foreach ($this->taxI18nsScheduledForDeletion as $taxI18nRemoved) { + $this->taxI18nsScheduledForDeletion = unserialize(serialize($taxI18nsToDelete)); + + foreach ($taxI18nsToDelete as $taxI18nRemoved) { $taxI18nRemoved->setTax(null); } @@ -1481,6 +1510,8 @@ abstract class BaseTax extends BaseObject implements Persistent $this->collTaxI18ns = $taxI18ns; $this->collTaxI18nsPartial = false; + + return $this; } /** @@ -1498,22 +1529,22 @@ abstract class BaseTax extends BaseObject implements Persistent if (null === $this->collTaxI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTaxI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxI18ns()); - } - $query = TaxI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTax($this) - ->count($con); } - } else { - return count($this->collTaxI18ns); + + if($partial && !$criteria) { + return count($this->getTaxI18ns()); + } + $query = TaxI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTax($this) + ->count($con); } + + return count($this->collTaxI18ns); } /** @@ -1533,7 +1564,7 @@ abstract class BaseTax extends BaseObject implements Persistent $this->initTaxI18ns(); $this->collTaxI18nsPartial = true; } - if (!$this->collTaxI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collTaxI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxI18n($l); } @@ -1551,6 +1582,7 @@ abstract class BaseTax extends BaseObject implements Persistent /** * @param TaxI18n $taxI18n The taxI18n object to remove. + * @return Tax The current object (for fluent API support) */ public function removeTaxI18n($taxI18n) { @@ -1560,9 +1592,11 @@ abstract class BaseTax extends BaseObject implements Persistent $this->taxI18nsScheduledForDeletion = clone $this->collTaxI18ns; $this->taxI18nsScheduledForDeletion->clear(); } - $this->taxI18nsScheduledForDeletion[]= $taxI18n; + $this->taxI18nsScheduledForDeletion[]= clone $taxI18n; $taxI18n->setTax(null); } + + return $this; } /** @@ -1576,6 +1610,7 @@ abstract class BaseTax extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1593,7 +1628,8 @@ abstract class BaseTax extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collTaxRuleCountrys) { foreach ($this->collTaxRuleCountrys as $o) { $o->clearAllReferences($deep); @@ -1604,10 +1640,12 @@ abstract class BaseTax extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collTaxRuleCountrys instanceof PropelCollection) { @@ -1663,7 +1701,7 @@ abstract class BaseTax extends BaseObject implements Persistent * * @return Tax The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1687,7 +1725,7 @@ abstract class BaseTax extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return TaxI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxI18ns) { @@ -1722,7 +1760,7 @@ abstract class BaseTax extends BaseObject implements Persistent * * @return Tax The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { TaxI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseTaxI18n.php b/core/lib/Thelia/Model/om/BaseTaxI18n.php index 07763ac61..0b9c8c565 100644 --- a/core/lib/Thelia/Model/om/BaseTaxI18n.php +++ b/core/lib/Thelia/Model/om/BaseTaxI18n.php @@ -53,7 +53,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -89,6 +89,12 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -97,7 +103,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -158,7 +164,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -183,7 +189,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -204,7 +210,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -225,7 +231,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -248,7 +254,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -285,7 +291,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 4; // 4 = TaxI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -511,16 +517,16 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TaxI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(TaxI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } if ($this->isColumnModified(TaxI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(TaxI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } $sql = sprintf( @@ -533,16 +539,16 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; } @@ -606,11 +612,11 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -986,12 +992,13 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent * Get the associated Tax object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Tax The associated Tax object. * @throws PropelException */ - public function getTax(PropelPDO $con = null) + public function getTax(PropelPDO $con = null, $doQuery = true) { - if ($this->aTax === null && ($this->id !== null)) { + if ($this->aTax === null && ($this->id !== null) && $doQuery) { $this->aTax = TaxQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1016,6 +1023,7 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent $this->description = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1034,7 +1042,13 @@ abstract class BaseTaxI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aTax instanceof Persistent) { + $this->aTax->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aTax = null; diff --git a/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php b/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php index 6efb315e9..f8f0b8bdc 100644 --- a/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php @@ -45,17 +45,17 @@ abstract class BaseTaxI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'tax_i18n.ID'; + /** the column name for the id field */ + const ID = 'tax_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'tax_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'tax_i18n.locale'; - /** the column name for the TITLE field */ - const TITLE = 'tax_i18n.TITLE'; + /** the column name for the title field */ + const TITLE = 'tax_i18n.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'tax_i18n.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'tax_i18n.description'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -175,10 +175,10 @@ abstract class BaseTaxI18nPeer $criteria->addSelectColumn(TaxI18nPeer::TITLE); $criteria->addSelectColumn(TaxI18nPeer::DESCRIPTION); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); } } @@ -262,7 +262,7 @@ abstract class BaseTaxI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -367,8 +367,15 @@ abstract class BaseTaxI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (TaxI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } TaxI18nPeer::$instances = array(); } @@ -741,7 +748,7 @@ abstract class BaseTaxI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return TaxI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php b/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php index 30750361c..6d41da4e4 100644 --- a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php @@ -73,7 +73,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * Returns a new TaxI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param TaxI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param TaxI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return TaxI18nQuery */ @@ -137,12 +137,12 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return TaxI18n A model object, or null if the key is not found - * @throws PropelException + * @return TaxI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE`, `TITLE`, `DESCRIPTION` FROM `tax_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale`, `title`, `description` FROM `tax_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -250,7 +250,8 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByTax() @@ -265,8 +266,22 @@ abstract class BaseTaxI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TaxI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(TaxI18nPeer::ID, $id, $comparison); @@ -365,8 +380,8 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTax($tax, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseTaxPeer.php b/core/lib/Thelia/Model/om/BaseTaxPeer.php index 31e205686..2b694ae47 100644 --- a/core/lib/Thelia/Model/om/BaseTaxPeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxPeer.php @@ -46,17 +46,17 @@ abstract class BaseTaxPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 4; - /** the column name for the ID field */ - const ID = 'tax.ID'; + /** the column name for the id field */ + const ID = 'tax.id'; - /** the column name for the RATE field */ - const RATE = 'tax.RATE'; + /** the column name for the rate field */ + const RATE = 'tax.rate'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'tax.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'tax.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'tax.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'tax.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -76,7 +76,7 @@ abstract class BaseTaxPeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -183,10 +183,10 @@ abstract class BaseTaxPeer $criteria->addSelectColumn(TaxPeer::CREATED_AT); $criteria->addSelectColumn(TaxPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.RATE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.rate'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -270,7 +270,7 @@ abstract class BaseTaxPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -375,8 +375,15 @@ abstract class BaseTaxPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (TaxPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } TaxPeer::$instances = array(); } @@ -517,7 +524,7 @@ abstract class BaseTaxPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return TaxPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/om/BaseTaxQuery.php index e84cc24bd..5149f7e81 100644 --- a/core/lib/Thelia/Model/om/BaseTaxQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxQuery.php @@ -48,7 +48,6 @@ use Thelia\Model\TaxRuleCountry; * @method Tax findOne(PropelPDO $con = null) Return the first Tax matching the query * @method Tax findOneOrCreate(PropelPDO $con = null) Return the first Tax matching the query, or a new Tax object populated from the query conditions when no match is found * - * @method Tax findOneById(int $id) Return the first Tax filtered by the id column * @method Tax findOneByRate(double $rate) Return the first Tax filtered by the rate column * @method Tax findOneByCreatedAt(string $created_at) Return the first Tax filtered by the created_at column * @method Tax findOneByUpdatedAt(string $updated_at) Return the first Tax filtered by the updated_at column @@ -78,7 +77,7 @@ abstract class BaseTaxQuery extends ModelCriteria * Returns a new TaxQuery object. * * @param string $modelAlias The alias of a model in the query - * @param TaxQuery|Criteria $criteria Optional Criteria to build the query from + * @param TaxQuery|Criteria $criteria Optional Criteria to build the query from * * @return TaxQuery */ @@ -134,6 +133,20 @@ abstract class BaseTaxQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Tax A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -141,12 +154,12 @@ abstract class BaseTaxQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return Tax A model object, or null if the key is not found - * @throws PropelException + * @return Tax A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `RATE`, `CREATED_AT`, `UPDATED_AT` FROM `tax` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `rate`, `created_at`, `updated_at` FROM `tax` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -242,7 +255,8 @@ abstract class BaseTaxQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -255,8 +269,22 @@ abstract class BaseTaxQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TaxPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(TaxPeer::ID, $id, $comparison); @@ -269,7 +297,8 @@ abstract class BaseTaxQuery extends ModelCriteria * * $query->filterByRate(1234); // WHERE rate = 1234 * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34) - * $query->filterByRate(array('min' => 12)); // WHERE rate > 12 + * $query->filterByRate(array('min' => 12)); // WHERE rate >= 12 + * $query->filterByRate(array('max' => 12)); // WHERE rate <= 12 * * * @param mixed $rate The value to use as filter. @@ -395,8 +424,8 @@ abstract class BaseTaxQuery extends ModelCriteria * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { @@ -469,8 +498,8 @@ abstract class BaseTaxQuery extends ModelCriteria * @param TaxI18n|PropelObjectCollection $taxI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxI18n($taxI18n, $comparison = null) { @@ -629,7 +658,7 @@ abstract class BaseTaxQuery extends ModelCriteria * * @return TaxQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; @@ -647,7 +676,7 @@ abstract class BaseTaxQuery extends ModelCriteria * * @return TaxQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -668,7 +697,7 @@ abstract class BaseTaxQuery extends ModelCriteria * * @return TaxI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/om/BaseTaxRule.php index e7859aef6..5c86263c1 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRule.php +++ b/core/lib/Thelia/Model/om/BaseTaxRule.php @@ -121,13 +121,19 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + // i18n behavior /** * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -212,22 +218,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -249,22 +258,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -275,7 +287,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -296,7 +308,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function setCode($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -317,7 +329,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function setTitle($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -338,7 +350,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function setDescription($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -442,7 +454,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 6; // 6 = TaxRulePeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -658,7 +670,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($this->collProducts !== null) { foreach ($this->collProducts as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -676,7 +688,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($this->collTaxRuleCountrys !== null) { foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -693,7 +705,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($this->collTaxRuleI18ns !== null) { foreach ($this->collTaxRuleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted()) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } @@ -726,22 +738,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TaxRulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(TaxRulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`CODE`'; + $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(TaxRulePeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`TITLE`'; + $modifiedColumns[':p' . $index++] = '`title`'; } if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`DESCRIPTION`'; + $modifiedColumns[':p' . $index++] = '`description`'; } if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -754,22 +766,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`CODE`': + case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`TITLE`': + case '`title`': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`DESCRIPTION`': + case '`description`': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -840,11 +852,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1265,13 +1277,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return TaxRule The current object (for fluent API support) * @see addProducts() */ public function clearProducts() { $this->collProducts = null; // important to set this to null since that means it is uninitialized $this->collProductsPartial = null; + + return $this; } /** @@ -1343,6 +1357,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collProductsPartial = true; } + $collProducts->getInternalIterator()->rewind(); return $collProducts; } @@ -1370,12 +1385,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @param PropelCollection $products A Propel collection. * @param PropelPDO $con Optional connection object + * @return TaxRule The current object (for fluent API support) */ public function setProducts(PropelCollection $products, PropelPDO $con = null) { - $this->productsScheduledForDeletion = $this->getProducts(new Criteria(), $con)->diff($products); + $productsToDelete = $this->getProducts(new Criteria(), $con)->diff($products); - foreach ($this->productsScheduledForDeletion as $productRemoved) { + $this->productsScheduledForDeletion = unserialize(serialize($productsToDelete)); + + foreach ($productsToDelete as $productRemoved) { $productRemoved->setTaxRule(null); } @@ -1386,6 +1404,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collProducts = $products; $this->collProductsPartial = false; + + return $this; } /** @@ -1403,22 +1423,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null === $this->collProducts || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProducts) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getProducts()); - } - $query = ProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); } - } else { - return count($this->collProducts); + + if($partial && !$criteria) { + return count($this->getProducts()); + } + $query = ProductQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTaxRule($this) + ->count($con); } + + return count($this->collProducts); } /** @@ -1434,7 +1454,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->initProducts(); $this->collProductsPartial = true; } - if (!$this->collProducts->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProduct($l); } @@ -1452,6 +1472,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * @param Product $product The product object to remove. + * @return TaxRule The current object (for fluent API support) */ public function removeProduct($product) { @@ -1464,6 +1485,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->productsScheduledForDeletion[]= $product; $product->setTaxRule(null); } + + return $this; } /** @@ -1472,13 +1495,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return TaxRule The current object (for fluent API support) * @see addTaxRuleCountrys() */ public function clearTaxRuleCountrys() { $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized $this->collTaxRuleCountrysPartial = null; + + return $this; } /** @@ -1550,6 +1575,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collTaxRuleCountrysPartial = true; } + $collTaxRuleCountrys->getInternalIterator()->rewind(); return $collTaxRuleCountrys; } @@ -1577,12 +1603,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @param PropelCollection $taxRuleCountrys A Propel collection. * @param PropelPDO $con Optional connection object + * @return TaxRule The current object (for fluent API support) */ public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) { - $this->taxRuleCountrysScheduledForDeletion = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); + $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountryRemoved) { + $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); + + foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { $taxRuleCountryRemoved->setTaxRule(null); } @@ -1593,6 +1622,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collTaxRuleCountrys = $taxRuleCountrys; $this->collTaxRuleCountrysPartial = false; + + return $this; } /** @@ -1610,22 +1641,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTaxRuleCountrys) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); } - } else { - return count($this->collTaxRuleCountrys); + + if($partial && !$criteria) { + return count($this->getTaxRuleCountrys()); + } + $query = TaxRuleCountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTaxRule($this) + ->count($con); } + + return count($this->collTaxRuleCountrys); } /** @@ -1641,7 +1672,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->initTaxRuleCountrys(); $this->collTaxRuleCountrysPartial = true; } - if (!$this->collTaxRuleCountrys->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleCountry($l); } @@ -1659,6 +1690,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return TaxRule The current object (for fluent API support) */ public function removeTaxRuleCountry($taxRuleCountry) { @@ -1671,6 +1703,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; $taxRuleCountry->setTaxRule(null); } + + return $this; } @@ -1729,13 +1763,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * - * @return void + * @return TaxRule The current object (for fluent API support) * @see addTaxRuleI18ns() */ public function clearTaxRuleI18ns() { $this->collTaxRuleI18ns = null; // important to set this to null since that means it is uninitialized $this->collTaxRuleI18nsPartial = null; + + return $this; } /** @@ -1807,6 +1843,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collTaxRuleI18nsPartial = true; } + $collTaxRuleI18ns->getInternalIterator()->rewind(); return $collTaxRuleI18ns; } @@ -1834,12 +1871,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @param PropelCollection $taxRuleI18ns A Propel collection. * @param PropelPDO $con Optional connection object + * @return TaxRule The current object (for fluent API support) */ public function setTaxRuleI18ns(PropelCollection $taxRuleI18ns, PropelPDO $con = null) { - $this->taxRuleI18nsScheduledForDeletion = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns); + $taxRuleI18nsToDelete = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns); - foreach ($this->taxRuleI18nsScheduledForDeletion as $taxRuleI18nRemoved) { + $this->taxRuleI18nsScheduledForDeletion = unserialize(serialize($taxRuleI18nsToDelete)); + + foreach ($taxRuleI18nsToDelete as $taxRuleI18nRemoved) { $taxRuleI18nRemoved->setTaxRule(null); } @@ -1850,6 +1890,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collTaxRuleI18ns = $taxRuleI18ns; $this->collTaxRuleI18nsPartial = false; + + return $this; } /** @@ -1867,22 +1909,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collTaxRuleI18ns) { return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxRuleI18ns()); - } - $query = TaxRuleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); } - } else { - return count($this->collTaxRuleI18ns); + + if($partial && !$criteria) { + return count($this->getTaxRuleI18ns()); + } + $query = TaxRuleI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTaxRule($this) + ->count($con); } + + return count($this->collTaxRuleI18ns); } /** @@ -1902,7 +1944,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->initTaxRuleI18ns(); $this->collTaxRuleI18nsPartial = true; } - if (!$this->collTaxRuleI18ns->contains($l)) { // only add it if the **same** object is not already associated + if (!in_array($l, $this->collTaxRuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleI18n($l); } @@ -1920,6 +1962,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove. + * @return TaxRule The current object (for fluent API support) */ public function removeTaxRuleI18n($taxRuleI18n) { @@ -1929,9 +1972,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->taxRuleI18nsScheduledForDeletion = clone $this->collTaxRuleI18ns; $this->taxRuleI18nsScheduledForDeletion->clear(); } - $this->taxRuleI18nsScheduledForDeletion[]= $taxRuleI18n; + $this->taxRuleI18nsScheduledForDeletion[]= clone $taxRuleI18n; $taxRuleI18n->setTaxRule(null); } + + return $this; } /** @@ -1947,6 +1992,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1964,7 +2010,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; if ($this->collProducts) { foreach ($this->collProducts as $o) { $o->clearAllReferences($deep); @@ -1980,10 +2027,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProducts instanceof PropelCollection) { @@ -2043,7 +2092,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @return TaxRule The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2067,7 +2116,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * @param PropelPDO $con an optional connection object * * @return TaxRuleI18n */ - public function getTranslation($locale = 'en_EN', PropelPDO $con = null) + public function getTranslation($locale = 'en_US', PropelPDO $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxRuleI18ns) { @@ -2102,7 +2151,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @return TaxRule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', PropelPDO $con = null) + public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { TaxRuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php index af89f156c..9f60627f2 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php @@ -122,6 +122,12 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Get the [id] column value. * @@ -191,22 +197,25 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->created_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); - } + } + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -228,22 +237,25 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent // while technically this is not a default value of null, // this seems to be closest in meaning. return null; - } else { - try { - $dt = new DateTime($this->updated_at); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); - } + } + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; - } elseif (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } else { - return $dt->format($format); } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + } /** @@ -254,7 +266,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -275,7 +287,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function setTaxRuleId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -300,7 +312,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function setCountryId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -325,7 +337,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function setTaxId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -350,7 +362,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function setNone($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -455,7 +467,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 7; // 7 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -714,25 +726,25 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TaxRuleCountryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(TaxRuleCountryPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`'; + $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; } if ($this->isColumnModified(TaxRuleCountryPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`'; + $modifiedColumns[':p' . $index++] = '`country_id`'; } if ($this->isColumnModified(TaxRuleCountryPeer::TAX_ID)) { - $modifiedColumns[':p' . $index++] = '`TAX_ID`'; + $modifiedColumns[':p' . $index++] = '`tax_id`'; } if ($this->isColumnModified(TaxRuleCountryPeer::NONE)) { - $modifiedColumns[':p' . $index++] = '`NONE`'; + $modifiedColumns[':p' . $index++] = '`none`'; } if ($this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + $modifiedColumns[':p' . $index++] = '`updated_at`'; } $sql = sprintf( @@ -745,25 +757,25 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`TAX_RULE_ID`': + case '`tax_rule_id`': $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); break; - case '`COUNTRY_ID`': + case '`country_id`': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`TAX_ID`': + case '`tax_id`': $stmt->bindValue($identifier, $this->tax_id, PDO::PARAM_INT); break; - case '`NONE`': + case '`none`': $stmt->bindValue($identifier, $this->none, PDO::PARAM_INT); break; - case '`CREATED_AT`': + case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATED_AT`': + case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } @@ -827,11 +839,11 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -1248,12 +1260,13 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent * Get the associated Tax object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Tax The associated Tax object. * @throws PropelException */ - public function getTax(PropelPDO $con = null) + public function getTax(PropelPDO $con = null, $doQuery = true) { - if ($this->aTax === null && ($this->tax_id !== null)) { + if ($this->aTax === null && ($this->tax_id !== null) && $doQuery) { $this->aTax = TaxQuery::create()->findPk($this->tax_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1299,12 +1312,13 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent * Get the associated TaxRule object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return TaxRule The associated TaxRule object. * @throws PropelException */ - public function getTaxRule(PropelPDO $con = null) + public function getTaxRule(PropelPDO $con = null, $doQuery = true) { - if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) { + if ($this->aTaxRule === null && ($this->tax_rule_id !== null) && $doQuery) { $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1350,12 +1364,13 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent * Get the associated Country object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return Country The associated Country object. * @throws PropelException */ - public function getCountry(PropelPDO $con = null) + public function getCountry(PropelPDO $con = null, $doQuery = true) { - if ($this->aCountry === null && ($this->country_id !== null)) { + if ($this->aCountry === null && ($this->country_id !== null) && $doQuery) { $this->aCountry = CountryQuery::create()->findPk($this->country_id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -1383,6 +1398,7 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1400,7 +1416,19 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aTax instanceof Persistent) { + $this->aTax->clearAllReferences($deep); + } + if ($this->aTaxRule instanceof Persistent) { + $this->aTaxRule->clearAllReferences($deep); + } + if ($this->aCountry instanceof Persistent) { + $this->aCountry->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aTax = null; diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php index f068a8a8f..feb536176 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php @@ -47,26 +47,26 @@ abstract class BaseTaxRuleCountryPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 7; - /** the column name for the ID field */ - const ID = 'tax_rule_country.ID'; + /** the column name for the id field */ + const ID = 'tax_rule_country.id'; - /** the column name for the TAX_RULE_ID field */ - const TAX_RULE_ID = 'tax_rule_country.TAX_RULE_ID'; + /** the column name for the tax_rule_id field */ + const TAX_RULE_ID = 'tax_rule_country.tax_rule_id'; - /** the column name for the COUNTRY_ID field */ - const COUNTRY_ID = 'tax_rule_country.COUNTRY_ID'; + /** the column name for the country_id field */ + const COUNTRY_ID = 'tax_rule_country.country_id'; - /** the column name for the TAX_ID field */ - const TAX_ID = 'tax_rule_country.TAX_ID'; + /** the column name for the tax_id field */ + const TAX_ID = 'tax_rule_country.tax_id'; - /** the column name for the NONE field */ - const NONE = 'tax_rule_country.NONE'; + /** the column name for the none field */ + const NONE = 'tax_rule_country.none'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'tax_rule_country.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'tax_rule_country.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'tax_rule_country.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'tax_rule_country.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -189,13 +189,13 @@ abstract class BaseTaxRuleCountryPeer $criteria->addSelectColumn(TaxRuleCountryPeer::CREATED_AT); $criteria->addSelectColumn(TaxRuleCountryPeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TAX_RULE_ID'); - $criteria->addSelectColumn($alias . '.COUNTRY_ID'); - $criteria->addSelectColumn($alias . '.TAX_ID'); - $criteria->addSelectColumn($alias . '.NONE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.tax_rule_id'); + $criteria->addSelectColumn($alias . '.country_id'); + $criteria->addSelectColumn($alias . '.tax_id'); + $criteria->addSelectColumn($alias . '.none'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -279,7 +279,7 @@ abstract class BaseTaxRuleCountryPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -384,8 +384,15 @@ abstract class BaseTaxRuleCountryPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (TaxRuleCountryPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } TaxRuleCountryPeer::$instances = array(); } @@ -1497,7 +1504,7 @@ abstract class BaseTaxRuleCountryPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return TaxRuleCountryPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php index cb0dad946..c78697899 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php @@ -59,7 +59,6 @@ use Thelia\Model\TaxRuleCountryQuery; * @method TaxRuleCountry findOne(PropelPDO $con = null) Return the first TaxRuleCountry matching the query * @method TaxRuleCountry findOneOrCreate(PropelPDO $con = null) Return the first TaxRuleCountry matching the query, or a new TaxRuleCountry object populated from the query conditions when no match is found * - * @method TaxRuleCountry findOneById(int $id) Return the first TaxRuleCountry filtered by the id column * @method TaxRuleCountry findOneByTaxRuleId(int $tax_rule_id) Return the first TaxRuleCountry filtered by the tax_rule_id column * @method TaxRuleCountry findOneByCountryId(int $country_id) Return the first TaxRuleCountry filtered by the country_id column * @method TaxRuleCountry findOneByTaxId(int $tax_id) Return the first TaxRuleCountry filtered by the tax_id column @@ -95,7 +94,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * Returns a new TaxRuleCountryQuery object. * * @param string $modelAlias The alias of a model in the query - * @param TaxRuleCountryQuery|Criteria $criteria Optional Criteria to build the query from + * @param TaxRuleCountryQuery|Criteria $criteria Optional Criteria to build the query from * * @return TaxRuleCountryQuery */ @@ -151,6 +150,20 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return TaxRuleCountry A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -158,12 +171,12 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return TaxRuleCountry A model object, or null if the key is not found - * @throws PropelException + * @return TaxRuleCountry A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TAX_RULE_ID`, `COUNTRY_ID`, `TAX_ID`, `NONE`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule_country` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `tax_rule_id`, `country_id`, `tax_id`, `none`, `created_at`, `updated_at` FROM `tax_rule_country` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -259,7 +272,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -272,8 +286,22 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TaxRuleCountryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxRuleCountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(TaxRuleCountryPeer::ID, $id, $comparison); @@ -286,7 +314,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234 * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34) - * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id >= 12 + * $query->filterByTaxRuleId(array('max' => 12)); // WHERE tax_rule_id <= 12 * * * @see filterByTaxRule() @@ -329,7 +358,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $query->filterByCountryId(1234); // WHERE country_id = 1234 * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 + * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 * * * @see filterByCountry() @@ -372,7 +402,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $query->filterByTaxId(1234); // WHERE tax_id = 1234 * $query->filterByTaxId(array(12, 34)); // WHERE tax_id IN (12, 34) - * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12 + * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id >= 12 + * $query->filterByTaxId(array('max' => 12)); // WHERE tax_id <= 12 * * * @see filterByTax() @@ -415,7 +446,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $query->filterByNone(1234); // WHERE none = 1234 * $query->filterByNone(array(12, 34)); // WHERE none IN (12, 34) - * $query->filterByNone(array('min' => 12)); // WHERE none > 12 + * $query->filterByNone(array('min' => 12)); // WHERE none >= 12 + * $query->filterByNone(array('max' => 12)); // WHERE none <= 12 * * * @param mixed $none The value to use as filter. @@ -541,8 +573,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleCountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTax($tax, $comparison = null) { @@ -617,8 +649,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleCountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRule($taxRule, $comparison = null) { @@ -693,8 +725,8 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @param Country|PropelObjectCollection $country The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleCountryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByCountry($country, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php index 5735f6b9a..3396b673b 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php @@ -53,7 +53,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -77,6 +77,12 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -85,7 +91,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -126,7 +132,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ public function setId($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (int) $v; } @@ -151,7 +157,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ public function setLocale($v) { - if ($v !== null) { + if ($v !== null && is_numeric($v)) { $v = (string) $v; } @@ -174,7 +180,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } @@ -209,7 +215,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - + $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 2; // 2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { @@ -435,10 +441,10 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TaxRuleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`ID`'; + $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`LOCALE`'; + $modifiedColumns[':p' . $index++] = '`locale`'; } $sql = sprintf( @@ -451,10 +457,10 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`ID`': + case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`LOCALE`': + case '`locale`': $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); break; } @@ -518,11 +524,11 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent $this->validationFailures = array(); return true; - } else { - $this->validationFailures = $res; - - return false; } + + $this->validationFailures = $res; + + return false; } /** @@ -878,12 +884,13 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent * Get the associated TaxRule object * * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required * @return TaxRule The associated TaxRule object. * @throws PropelException */ - public function getTaxRule(PropelPDO $con = null) + public function getTaxRule(PropelPDO $con = null, $doQuery = true) { - if ($this->aTaxRule === null && ($this->id !== null)) { + if ($this->aTaxRule === null && ($this->id !== null) && $doQuery) { $this->aTaxRule = TaxRuleQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference @@ -906,6 +913,7 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent $this->locale = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -924,7 +932,13 @@ abstract class BaseTaxRuleI18n extends BaseObject implements Persistent */ public function clearAllReferences($deep = false) { - if ($deep) { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aTaxRule instanceof Persistent) { + $this->aTaxRule->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aTaxRule = null; diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php index 46740708d..fc1dfed70 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php @@ -45,11 +45,11 @@ abstract class BaseTaxRuleI18nPeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 2; - /** the column name for the ID field */ - const ID = 'tax_rule_i18n.ID'; + /** the column name for the id field */ + const ID = 'tax_rule_i18n.id'; - /** the column name for the LOCALE field */ - const LOCALE = 'tax_rule_i18n.LOCALE'; + /** the column name for the locale field */ + const LOCALE = 'tax_rule_i18n.locale'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -167,8 +167,8 @@ abstract class BaseTaxRuleI18nPeer $criteria->addSelectColumn(TaxRuleI18nPeer::ID); $criteria->addSelectColumn(TaxRuleI18nPeer::LOCALE); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale'); } } @@ -252,7 +252,7 @@ abstract class BaseTaxRuleI18nPeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -357,8 +357,15 @@ abstract class BaseTaxRuleI18nPeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (TaxRuleI18nPeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } TaxRuleI18nPeer::$instances = array(); } @@ -731,7 +738,7 @@ abstract class BaseTaxRuleI18nPeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return TaxRuleI18nPeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php index 85dcf2fc8..9bf286bc6 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php @@ -65,7 +65,7 @@ abstract class BaseTaxRuleI18nQuery extends ModelCriteria * Returns a new TaxRuleI18nQuery object. * * @param string $modelAlias The alias of a model in the query - * @param TaxRuleI18nQuery|Criteria $criteria Optional Criteria to build the query from + * @param TaxRuleI18nQuery|Criteria $criteria Optional Criteria to build the query from * * @return TaxRuleI18nQuery */ @@ -129,12 +129,12 @@ abstract class BaseTaxRuleI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return TaxRuleI18n A model object, or null if the key is not found - * @throws PropelException + * @return TaxRuleI18n A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `LOCALE` FROM `tax_rule_i18n` WHERE `ID` = :p0 AND `LOCALE` = :p1'; + $sql = 'SELECT `id`, `locale` FROM `tax_rule_i18n` WHERE `id` = :p0 AND `locale` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -242,7 +242,8 @@ abstract class BaseTaxRuleI18nQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @see filterByTaxRule() @@ -257,8 +258,22 @@ abstract class BaseTaxRuleI18nQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(TaxRuleI18nPeer::ID, $id, $comparison); @@ -299,8 +314,8 @@ abstract class BaseTaxRuleI18nQuery extends ModelCriteria * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleI18nQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRule($taxRule, $comparison = null) { diff --git a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php index 9a771852f..bf825eb9f 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php @@ -47,23 +47,23 @@ abstract class BaseTaxRulePeer /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ const NUM_HYDRATE_COLUMNS = 6; - /** the column name for the ID field */ - const ID = 'tax_rule.ID'; + /** the column name for the id field */ + const ID = 'tax_rule.id'; - /** the column name for the CODE field */ - const CODE = 'tax_rule.CODE'; + /** the column name for the code field */ + const CODE = 'tax_rule.code'; - /** the column name for the TITLE field */ - const TITLE = 'tax_rule.TITLE'; + /** the column name for the title field */ + const TITLE = 'tax_rule.title'; - /** the column name for the DESCRIPTION field */ - const DESCRIPTION = 'tax_rule.DESCRIPTION'; + /** the column name for the description field */ + const DESCRIPTION = 'tax_rule.description'; - /** the column name for the CREATED_AT field */ - const CREATED_AT = 'tax_rule.CREATED_AT'; + /** the column name for the created_at field */ + const CREATED_AT = 'tax_rule.created_at'; - /** the column name for the UPDATED_AT field */ - const UPDATED_AT = 'tax_rule.UPDATED_AT'; + /** the column name for the updated_at field */ + const UPDATED_AT = 'tax_rule.updated_at'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -83,7 +83,7 @@ abstract class BaseTaxRulePeer * The default locale to use for translations * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames * @@ -192,12 +192,12 @@ abstract class BaseTaxRulePeer $criteria->addSelectColumn(TaxRulePeer::CREATED_AT); $criteria->addSelectColumn(TaxRulePeer::UPDATED_AT); } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.code'); + $criteria->addSelectColumn($alias . '.title'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); } } @@ -281,7 +281,7 @@ abstract class BaseTaxRulePeer /** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * - * Use this method directly if you want to work with an executed statement durirectly (for example + * Use this method directly if you want to work with an executed statement directly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. @@ -386,8 +386,15 @@ abstract class BaseTaxRulePeer * * @return void */ - public static function clearInstancePool() + public static function clearInstancePool($and_clear_all_references = false) { + if ($and_clear_all_references) + { + foreach (TaxRulePeer::$instances as $instance) + { + $instance->clearAllReferences(true); + } + } TaxRulePeer::$instances = array(); } @@ -531,7 +538,7 @@ abstract class BaseTaxRulePeer * * @return string ClassName */ - public static function getOMClass() + public static function getOMClass($row = 0, $colnum = 0) { return TaxRulePeer::OM_CLASS; } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php index 2468cd7eb..5829651c3 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php @@ -57,7 +57,6 @@ use Thelia\Model\TaxRuleQuery; * @method TaxRule findOne(PropelPDO $con = null) Return the first TaxRule matching the query * @method TaxRule findOneOrCreate(PropelPDO $con = null) Return the first TaxRule matching the query, or a new TaxRule object populated from the query conditions when no match is found * - * @method TaxRule findOneById(int $id) Return the first TaxRule filtered by the id column * @method TaxRule findOneByCode(string $code) Return the first TaxRule filtered by the code column * @method TaxRule findOneByTitle(string $title) Return the first TaxRule filtered by the title column * @method TaxRule findOneByDescription(string $description) Return the first TaxRule filtered by the description column @@ -91,7 +90,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * Returns a new TaxRuleQuery object. * * @param string $modelAlias The alias of a model in the query - * @param TaxRuleQuery|Criteria $criteria Optional Criteria to build the query from + * @param TaxRuleQuery|Criteria $criteria Optional Criteria to build the query from * * @return TaxRuleQuery */ @@ -147,6 +146,20 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return TaxRule A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + /** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. @@ -154,12 +167,12 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * - * @return TaxRule A model object, or null if the key is not found - * @throws PropelException + * @return TaxRule A model object, or null if the key is not found + * @throws PropelException */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `TITLE`, `DESCRIPTION`, `CREATED_AT`, `UPDATED_AT` FROM `tax_rule` WHERE `ID` = :p0'; + $sql = 'SELECT `id`, `code`, `title`, `description`, `created_at`, `updated_at` FROM `tax_rule` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -255,7 +268,8 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * $query->filterById(1234); // WHERE id = 1234 * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 * * * @param mixed $id The value to use as filter. @@ -268,8 +282,22 @@ abstract class BaseTaxRuleQuery extends ModelCriteria */ public function filterById($id = null, $comparison = null) { - if (is_array($id) && null === $comparison) { - $comparison = Criteria::IN; + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(TaxRulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } } return $this->addUsingAlias(TaxRulePeer::ID, $id, $comparison); @@ -454,8 +482,8 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @param Product|PropelObjectCollection $product the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { @@ -528,8 +556,8 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { @@ -602,8 +630,8 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @param TaxRuleI18n|PropelObjectCollection $taxRuleI18n the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. + * @return TaxRuleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. */ public function filterByTaxRuleI18n($taxRuleI18n, $comparison = null) { @@ -762,7 +790,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @return TaxRuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; @@ -780,7 +808,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @return TaxRuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -801,7 +829,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @return TaxRuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType)