diff --git a/core/lib/Thelia/Log/TlogDestinationConfig.php b/core/lib/Thelia/Log/TlogDestinationConfig.php index 4b1e6b74b..98fec28dd 100644 --- a/core/lib/Thelia/Log/TlogDestinationConfig.php +++ b/core/lib/Thelia/Log/TlogDestinationConfig.php @@ -59,7 +59,7 @@ class TlogDestinationConfig $config->setName($this->name); $config->setValue($this->default); $config->setHidden(1); - $config->setSecure(1); + $config->setSecured(1); $config->save(); } diff --git a/core/lib/Thelia/Model/map/AccessoryTableMap.php b/core/lib/Thelia/Model/map/AccessoryTableMap.php index 751c6e424..9693be79b 100644 --- a/core/lib/Thelia/Model/map/AccessoryTableMap.php +++ b/core/lib/Thelia/Model/map/AccessoryTableMap.php @@ -46,8 +46,8 @@ class AccessoryTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,8 +56,21 @@ class AccessoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ProductRelatedByProductId', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('ProductRelatedByAccessory', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('accessory' => 'id', ), 'CASCADE', null); + $this->addRelation('ProductRelatedByProductId', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ProductRelatedByAccessory', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('accessory' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AccessoryTableMap diff --git a/core/lib/Thelia/Model/map/AddressTableMap.php b/core/lib/Thelia/Model/map/AddressTableMap.php index ea9041a94..d1bd7cf74 100644 --- a/core/lib/Thelia/Model/map/AddressTableMap.php +++ b/core/lib/Thelia/Model/map/AddressTableMap.php @@ -56,8 +56,8 @@ class AddressTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -66,8 +66,21 @@ class AddressTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), null, null); + $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AddressTableMap diff --git a/core/lib/Thelia/Model/map/AdminGroupTableMap.php b/core/lib/Thelia/Model/map/AdminGroupTableMap.php index 9acd8ad4f..434cf1d82 100644 --- a/core/lib/Thelia/Model/map/AdminGroupTableMap.php +++ b/core/lib/Thelia/Model/map/AdminGroupTableMap.php @@ -45,8 +45,8 @@ class AdminGroupTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,8 +55,21 @@ class AdminGroupTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AdminGroupTableMap diff --git a/core/lib/Thelia/Model/map/AdminLogTableMap.php b/core/lib/Thelia/Model/map/AdminLogTableMap.php index 9728a97ee..1ebb93098 100644 --- a/core/lib/Thelia/Model/map/AdminLogTableMap.php +++ b/core/lib/Thelia/Model/map/AdminLogTableMap.php @@ -48,8 +48,8 @@ class AdminLogTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -60,4 +60,17 @@ class AdminLogTableMap extends TableMap { } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AdminLogTableMap diff --git a/core/lib/Thelia/Model/map/AdminTableMap.php b/core/lib/Thelia/Model/map/AdminTableMap.php index 4240335a3..125c9f9cc 100644 --- a/core/lib/Thelia/Model/map/AdminTableMap.php +++ b/core/lib/Thelia/Model/map/AdminTableMap.php @@ -49,8 +49,8 @@ class AdminTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class AdminTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', null, 'AdminGroups'); + $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AdminTableMap diff --git a/core/lib/Thelia/Model/map/AreaTableMap.php b/core/lib/Thelia/Model/map/AreaTableMap.php index 28c4e3cc8..c2768651f 100644 --- a/core/lib/Thelia/Model/map/AreaTableMap.php +++ b/core/lib/Thelia/Model/map/AreaTableMap.php @@ -45,8 +45,8 @@ class AreaTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,8 +55,21 @@ class AreaTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', null, 'Countrys'); - $this->addRelation('Delivzone', 'Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', null, 'Delivzones'); + $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countrys'); + $this->addRelation('Delivzone', 'Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AreaTableMap diff --git a/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php index 8aca46635..30f3a468f 100644 --- a/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeAvDescTableMap.php @@ -48,8 +48,8 @@ class AttributeAvDescTableMap extends TableMap $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('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class AttributeAvDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', null); + $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeAvDescTableMap diff --git a/core/lib/Thelia/Model/map/AttributeAvTableMap.php b/core/lib/Thelia/Model/map/AttributeAvTableMap.php index 4f1a03b92..5581fb919 100644 --- a/core/lib/Thelia/Model/map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeAvTableMap.php @@ -45,8 +45,8 @@ class AttributeAvTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,9 +55,22 @@ class AttributeAvTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null); - $this->addRelation('AttributeAvDesc', 'Thelia\\Model\\AttributeAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', null, 'AttributeAvDescs'); - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', null, 'AttributeCombinations'); + $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('AttributeAvDesc', 'Thelia\\Model\\AttributeAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT', 'AttributeAvDescs'); + $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeAvTableMap diff --git a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php index eca24088c..a77353836 100644 --- a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php @@ -45,8 +45,8 @@ class AttributeCategoryTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,8 +55,21 @@ class AttributeCategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeCategoryTableMap diff --git a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php index aa52a5702..6ddd955ca 100644 --- a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php @@ -46,8 +46,8 @@ class AttributeCombinationTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,9 +56,22 @@ class AttributeCombinationTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null); - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeCombinationTableMap diff --git a/core/lib/Thelia/Model/map/AttributeDescTableMap.php b/core/lib/Thelia/Model/map/AttributeDescTableMap.php index 084523b3a..8447b891e 100644 --- a/core/lib/Thelia/Model/map/AttributeDescTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeDescTableMap.php @@ -48,8 +48,8 @@ class AttributeDescTableMap extends TableMap $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('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class AttributeDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeDescTableMap diff --git a/core/lib/Thelia/Model/map/AttributeTableMap.php b/core/lib/Thelia/Model/map/AttributeTableMap.php index d9dd0f1e5..e7c62ef58 100644 --- a/core/lib/Thelia/Model/map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/map/AttributeTableMap.php @@ -44,8 +44,8 @@ class AttributeTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,10 +54,23 @@ class AttributeTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeAvs'); - $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeCategorys'); - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeCombinations'); - $this->addRelation('AttributeDesc', 'Thelia\\Model\\AttributeDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', null, 'AttributeDescs'); + $this->addRelation('AttributeDesc', 'Thelia\\Model\\AttributeDesc', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeDescs'); + $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeAvs'); + $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); + $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategorys'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // AttributeTableMap diff --git a/core/lib/Thelia/Model/map/CategoryDescTableMap.php b/core/lib/Thelia/Model/map/CategoryDescTableMap.php index 0c32a58d9..d05f50f86 100644 --- a/core/lib/Thelia/Model/map/CategoryDescTableMap.php +++ b/core/lib/Thelia/Model/map/CategoryDescTableMap.php @@ -49,8 +49,8 @@ class CategoryDescTableMap extends TableMap $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->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class CategoryDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CategoryDescTableMap diff --git a/core/lib/Thelia/Model/map/CategoryTableMap.php b/core/lib/Thelia/Model/map/CategoryTableMap.php index 2231277ac..166b8091c 100644 --- a/core/lib/Thelia/Model/map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/map/CategoryTableMap.php @@ -47,8 +47,8 @@ class CategoryTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,14 +57,27 @@ class CategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'AttributeCategorys'); - $this->addRelation('CategoryDesc', 'Thelia\\Model\\CategoryDesc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'CategoryDescs'); - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'ContentAssocs'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Documents'); - $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'FeatureCategorys'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Images'); - $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'ProductCategorys'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', null, 'Rewritings'); + $this->addRelation('CategoryDesc', 'Thelia\\Model\\CategoryDesc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDescs'); + $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategorys'); + $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategorys'); + $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategorys'); + $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); + $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Images'); + $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Documents'); + $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CategoryTableMap diff --git a/core/lib/Thelia/Model/map/CombinationTableMap.php b/core/lib/Thelia/Model/map/CombinationTableMap.php index 5b741dcc4..b975b1fbf 100644 --- a/core/lib/Thelia/Model/map/CombinationTableMap.php +++ b/core/lib/Thelia/Model/map/CombinationTableMap.php @@ -44,8 +44,8 @@ class CombinationTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,8 +54,21 @@ class CombinationTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', null, 'AttributeCombinations'); - $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', null, 'Stocks'); + $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); + $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT', 'Stocks'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CombinationTableMap diff --git a/core/lib/Thelia/Model/map/ConfigDescTableMap.php b/core/lib/Thelia/Model/map/ConfigDescTableMap.php index d0176ff14..a7a781c07 100644 --- a/core/lib/Thelia/Model/map/ConfigDescTableMap.php +++ b/core/lib/Thelia/Model/map/ConfigDescTableMap.php @@ -48,8 +48,8 @@ class ConfigDescTableMap extends TableMap $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('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class ConfigDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Config', 'Thelia\\Model\\Config', RelationMap::MANY_TO_ONE, array('config_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Config', 'Thelia\\Model\\Config', RelationMap::MANY_TO_ONE, array('config_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ConfigDescTableMap diff --git a/core/lib/Thelia/Model/map/ConfigTableMap.php b/core/lib/Thelia/Model/map/ConfigTableMap.php index 705a0ca0c..f009de1ba 100644 --- a/core/lib/Thelia/Model/map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/map/ConfigTableMap.php @@ -45,10 +45,10 @@ class ConfigTableMap extends TableMap $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('SECURE', 'Secure', 'TINYINT', true, null, 1); + $this->addColumn('SECURED', 'Secured', 'TINYINT', true, null, 1); $this->addColumn('HIDDEN', 'Hidden', 'TINYINT', true, null, 1); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,7 +57,20 @@ class ConfigTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ConfigDesc', 'Thelia\\Model\\ConfigDesc', RelationMap::ONE_TO_MANY, array('id' => 'config_id', ), 'CASCADE', null, 'ConfigDescs'); + $this->addRelation('ConfigDesc', 'Thelia\\Model\\ConfigDesc', RelationMap::ONE_TO_MANY, array('id' => 'config_id', ), 'CASCADE', 'RESTRICT', 'ConfigDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ConfigTableMap diff --git a/core/lib/Thelia/Model/map/ContentAssocTableMap.php b/core/lib/Thelia/Model/map/ContentAssocTableMap.php index 0650f7d4c..b0b0a8f39 100644 --- a/core/lib/Thelia/Model/map/ContentAssocTableMap.php +++ b/core/lib/Thelia/Model/map/ContentAssocTableMap.php @@ -57,9 +57,22 @@ class ContentAssocTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ContentAssocTableMap diff --git a/core/lib/Thelia/Model/map/ContentDescTableMap.php b/core/lib/Thelia/Model/map/ContentDescTableMap.php index 489d7a478..066bd4a83 100644 --- a/core/lib/Thelia/Model/map/ContentDescTableMap.php +++ b/core/lib/Thelia/Model/map/ContentDescTableMap.php @@ -49,8 +49,8 @@ class ContentDescTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class ContentDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ContentDescTableMap diff --git a/core/lib/Thelia/Model/map/ContentFolderTableMap.php b/core/lib/Thelia/Model/map/ContentFolderTableMap.php index f0fe4a58a..796e90234 100644 --- a/core/lib/Thelia/Model/map/ContentFolderTableMap.php +++ b/core/lib/Thelia/Model/map/ContentFolderTableMap.php @@ -44,6 +44,8 @@ class ContentFolderTableMap extends TableMap // 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); // validators } // initialize() @@ -52,8 +54,21 @@ class ContentFolderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ContentFolderTableMap diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php index 66712b485..566f1cd24 100644 --- a/core/lib/Thelia/Model/map/ContentTableMap.php +++ b/core/lib/Thelia/Model/map/ContentTableMap.php @@ -45,8 +45,8 @@ class ContentTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,12 +55,25 @@ class ContentTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentAssocs'); - $this->addRelation('ContentDesc', 'Thelia\\Model\\ContentDesc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentDescs'); - $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'ContentFolders'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Documents'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Images'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', null, 'Rewritings'); + $this->addRelation('ContentDesc', 'Thelia\\Model\\ContentDesc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentDescs'); + $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); + $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Images'); + $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Documents'); + $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); + $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ContentTableMap diff --git a/core/lib/Thelia/Model/map/CountryDescTableMap.php b/core/lib/Thelia/Model/map/CountryDescTableMap.php index fdc6dce94..d2c6e1d79 100644 --- a/core/lib/Thelia/Model/map/CountryDescTableMap.php +++ b/core/lib/Thelia/Model/map/CountryDescTableMap.php @@ -58,7 +58,20 @@ class CountryDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CountryDescTableMap diff --git a/core/lib/Thelia/Model/map/CountryTableMap.php b/core/lib/Thelia/Model/map/CountryTableMap.php index c8c11993c..c8ea73778 100644 --- a/core/lib/Thelia/Model/map/CountryTableMap.php +++ b/core/lib/Thelia/Model/map/CountryTableMap.php @@ -57,9 +57,22 @@ class CountryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', null); - $this->addRelation('CountryDesc', 'Thelia\\Model\\CountryDesc', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'CountryDescs'); - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'TaxRuleCountrys'); + $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('CountryDesc', 'Thelia\\Model\\CountryDesc', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'CountryDescs'); + $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountrys'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CountryTableMap diff --git a/core/lib/Thelia/Model/map/CouponOrderTableMap.php b/core/lib/Thelia/Model/map/CouponOrderTableMap.php index a769d0a95..9c84f7052 100644 --- a/core/lib/Thelia/Model/map/CouponOrderTableMap.php +++ b/core/lib/Thelia/Model/map/CouponOrderTableMap.php @@ -46,8 +46,8 @@ class CouponOrderTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,7 +56,20 @@ class CouponOrderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CouponOrderTableMap diff --git a/core/lib/Thelia/Model/map/CouponRuleTableMap.php b/core/lib/Thelia/Model/map/CouponRuleTableMap.php index 00eb5b987..5213b0607 100644 --- a/core/lib/Thelia/Model/map/CouponRuleTableMap.php +++ b/core/lib/Thelia/Model/map/CouponRuleTableMap.php @@ -47,8 +47,8 @@ class CouponRuleTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,7 +57,20 @@ class CouponRuleTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Coupon', 'Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Coupon', 'Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CouponRuleTableMap diff --git a/core/lib/Thelia/Model/map/CouponTableMap.php b/core/lib/Thelia/Model/map/CouponTableMap.php index c9a26eecf..ac1b4f980 100644 --- a/core/lib/Thelia/Model/map/CouponTableMap.php +++ b/core/lib/Thelia/Model/map/CouponTableMap.php @@ -50,8 +50,8 @@ class CouponTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -60,7 +60,20 @@ class CouponTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('CouponRule', 'Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'CouponRules'); + $this->addRelation('CouponRule', 'Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT', 'CouponRules'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CouponTableMap diff --git a/core/lib/Thelia/Model/map/CurrencyTableMap.php b/core/lib/Thelia/Model/map/CurrencyTableMap.php index 4a6b80439..e4ff7bd19 100644 --- a/core/lib/Thelia/Model/map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/map/CurrencyTableMap.php @@ -47,9 +47,9 @@ class CurrencyTableMap extends TableMap $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('DEFAULT_UTILITY', 'DefaultUtility', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, 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() @@ -58,7 +58,20 @@ class CurrencyTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', null, 'Orders'); + $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CurrencyTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTableMap.php b/core/lib/Thelia/Model/map/CustomerTableMap.php index 68f2d52af..59fa9be3a 100644 --- a/core/lib/Thelia/Model/map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTableMap.php @@ -64,8 +64,8 @@ class CustomerTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -74,9 +74,22 @@ class CustomerTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', null); - $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', null, 'Addresss'); - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', null, 'Orders'); + $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresss'); + $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CustomerTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php index 3e2f4408d..947ba2e66 100644 --- a/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTitleDescTableMap.php @@ -47,8 +47,8 @@ class CustomerTitleDescTableMap extends TableMap $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null); $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -60,4 +60,17 @@ class CustomerTitleDescTableMap extends TableMap $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'CASCADE', null); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CustomerTitleDescTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php index 6de110a47..111b00838 100644 --- a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php @@ -43,10 +43,10 @@ class CustomerTitleTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'INTEGER', true, null, 0); + $this->addColumn('BY_DEFAULT', 'ByDefault', 'INTEGER', true, null, 0); $this->addColumn('POSITION', 'Position', 'VARCHAR', true, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,9 +55,22 @@ class CustomerTitleTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), null, null, 'Addresss'); - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', null, 'Customers'); + $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', 'RESTRICT', 'Customers'); + $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresss'); $this->addRelation('CustomerTitleDesc', 'Thelia\\Model\\CustomerTitleDesc', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'CASCADE', null, 'CustomerTitleDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // CustomerTitleTableMap diff --git a/core/lib/Thelia/Model/map/DelivzoneTableMap.php b/core/lib/Thelia/Model/map/DelivzoneTableMap.php index 86c4fe5e4..a0e828669 100644 --- a/core/lib/Thelia/Model/map/DelivzoneTableMap.php +++ b/core/lib/Thelia/Model/map/DelivzoneTableMap.php @@ -45,8 +45,8 @@ class DelivzoneTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,7 +55,20 @@ class DelivzoneTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', null); + $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // DelivzoneTableMap diff --git a/core/lib/Thelia/Model/map/DocumentDescTableMap.php b/core/lib/Thelia/Model/map/DocumentDescTableMap.php index f181e3421..3881a6890 100644 --- a/core/lib/Thelia/Model/map/DocumentDescTableMap.php +++ b/core/lib/Thelia/Model/map/DocumentDescTableMap.php @@ -58,7 +58,20 @@ class DocumentDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('document_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('document_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // DocumentDescTableMap diff --git a/core/lib/Thelia/Model/map/DocumentTableMap.php b/core/lib/Thelia/Model/map/DocumentTableMap.php index b305f8a00..978887cac 100644 --- a/core/lib/Thelia/Model/map/DocumentTableMap.php +++ b/core/lib/Thelia/Model/map/DocumentTableMap.php @@ -49,8 +49,8 @@ class DocumentTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,11 +59,24 @@ class DocumentTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null); - $this->addRelation('DocumentDesc', 'Thelia\\Model\\DocumentDesc', RelationMap::ONE_TO_MANY, array('id' => 'document_id', ), 'CASCADE', null, 'DocumentDescs'); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('DocumentDesc', 'Thelia\\Model\\DocumentDesc', RelationMap::ONE_TO_MANY, array('id' => 'document_id', ), 'CASCADE', 'RESTRICT', 'DocumentDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // DocumentTableMap diff --git a/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php index 001844e65..66f6a0d3b 100644 --- a/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureAvDescTableMap.php @@ -48,6 +48,8 @@ class FeatureAvDescTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', true, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,7 +58,20 @@ class FeatureAvDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', null); + $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureAvDescTableMap diff --git a/core/lib/Thelia/Model/map/FeatureAvTableMap.php b/core/lib/Thelia/Model/map/FeatureAvTableMap.php index fa56c5b6e..e3825d68b 100644 --- a/core/lib/Thelia/Model/map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureAvTableMap.php @@ -44,8 +44,8 @@ class FeatureAvTableMap extends TableMap // 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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,9 +54,22 @@ class FeatureAvTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null); - $this->addRelation('FeatureAvDesc', 'Thelia\\Model\\FeatureAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', null, 'FeatureAvDescs'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', null, 'FeatureProds'); + $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('FeatureAvDesc', 'Thelia\\Model\\FeatureAvDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT', 'FeatureAvDescs'); + $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureAvTableMap diff --git a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php index 2aaedcba4..04f156c6d 100644 --- a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php @@ -45,8 +45,8 @@ class FeatureCategoryTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,8 +55,21 @@ class FeatureCategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureCategoryTableMap diff --git a/core/lib/Thelia/Model/map/FeatureDescTableMap.php b/core/lib/Thelia/Model/map/FeatureDescTableMap.php index dbff3c642..d31966ad4 100644 --- a/core/lib/Thelia/Model/map/FeatureDescTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureDescTableMap.php @@ -48,8 +48,8 @@ class FeatureDescTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'VARCHAR', false, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class FeatureDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureDescTableMap diff --git a/core/lib/Thelia/Model/map/FeatureProdTableMap.php b/core/lib/Thelia/Model/map/FeatureProdTableMap.php index 24cde96d3..2c0923347 100644 --- a/core/lib/Thelia/Model/map/FeatureProdTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureProdTableMap.php @@ -46,10 +46,10 @@ class FeatureProdTableMap extends TableMap $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('DEFAULT_UTILITY', 'DefaultUtility', 'VARCHAR', false, 255, null); + $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,9 +58,22 @@ class FeatureProdTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureProdTableMap diff --git a/core/lib/Thelia/Model/map/FeatureTableMap.php b/core/lib/Thelia/Model/map/FeatureTableMap.php index 4378e8489..84ec83b3b 100644 --- a/core/lib/Thelia/Model/map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/map/FeatureTableMap.php @@ -45,8 +45,8 @@ class FeatureTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,10 +55,23 @@ class FeatureTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureAvs'); - $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureCategorys'); - $this->addRelation('FeatureDesc', 'Thelia\\Model\\FeatureDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureDescs'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', null, 'FeatureProds'); + $this->addRelation('FeatureDesc', 'Thelia\\Model\\FeatureDesc', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureDescs'); + $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureAvs'); + $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); + $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategorys'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FeatureTableMap diff --git a/core/lib/Thelia/Model/map/FolderDescTableMap.php b/core/lib/Thelia/Model/map/FolderDescTableMap.php index 40f5aa1e3..20061eeef 100644 --- a/core/lib/Thelia/Model/map/FolderDescTableMap.php +++ b/core/lib/Thelia/Model/map/FolderDescTableMap.php @@ -49,8 +49,8 @@ class FolderDescTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class FolderDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FolderDescTableMap diff --git a/core/lib/Thelia/Model/map/FolderTableMap.php b/core/lib/Thelia/Model/map/FolderTableMap.php index bf0513351..20c65fcf6 100644 --- a/core/lib/Thelia/Model/map/FolderTableMap.php +++ b/core/lib/Thelia/Model/map/FolderTableMap.php @@ -47,8 +47,8 @@ class FolderTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,11 +57,24 @@ class FolderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'ContentFolders'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Documents'); - $this->addRelation('FolderDesc', 'Thelia\\Model\\FolderDesc', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'FolderDescs'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Images'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', null, 'Rewritings'); + $this->addRelation('FolderDesc', 'Thelia\\Model\\FolderDesc', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'FolderDescs'); + $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Images'); + $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Documents'); + $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); + $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // FolderTableMap diff --git a/core/lib/Thelia/Model/map/GroupDescTableMap.php b/core/lib/Thelia/Model/map/GroupDescTableMap.php index 543b7e66a..d31841fad 100644 --- a/core/lib/Thelia/Model/map/GroupDescTableMap.php +++ b/core/lib/Thelia/Model/map/GroupDescTableMap.php @@ -58,7 +58,20 @@ class GroupDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // GroupDescTableMap diff --git a/core/lib/Thelia/Model/map/GroupModuleTableMap.php b/core/lib/Thelia/Model/map/GroupModuleTableMap.php index 0224f234c..be397fb41 100644 --- a/core/lib/Thelia/Model/map/GroupModuleTableMap.php +++ b/core/lib/Thelia/Model/map/GroupModuleTableMap.php @@ -46,8 +46,8 @@ class GroupModuleTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,7 +57,20 @@ class GroupModuleTableMap extends TableMap public function buildRelations() { $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE'); - $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // GroupModuleTableMap diff --git a/core/lib/Thelia/Model/map/GroupResourceTableMap.php b/core/lib/Thelia/Model/map/GroupResourceTableMap.php index ba5d42e8c..a01225633 100644 --- a/core/lib/Thelia/Model/map/GroupResourceTableMap.php +++ b/core/lib/Thelia/Model/map/GroupResourceTableMap.php @@ -47,8 +47,8 @@ class GroupResourceTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,8 +57,21 @@ class GroupResourceTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // GroupResourceTableMap diff --git a/core/lib/Thelia/Model/map/GroupTableMap.php b/core/lib/Thelia/Model/map/GroupTableMap.php index 7b38a8781..21653cb4c 100644 --- a/core/lib/Thelia/Model/map/GroupTableMap.php +++ b/core/lib/Thelia/Model/map/GroupTableMap.php @@ -44,8 +44,8 @@ class GroupTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,10 +54,23 @@ class GroupTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', null, 'AdminGroups'); - $this->addRelation('GroupDesc', 'Thelia\\Model\\GroupDesc', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', null, 'GroupDescs'); + $this->addRelation('GroupDesc', 'Thelia\\Model\\GroupDesc', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'GroupDescs'); + $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); + $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'CASCADE', 'GroupModules'); - $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', null, 'GroupResources'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // GroupTableMap diff --git a/core/lib/Thelia/Model/map/ImageDescTableMap.php b/core/lib/Thelia/Model/map/ImageDescTableMap.php index 9aa41ad64..c6fc288a0 100644 --- a/core/lib/Thelia/Model/map/ImageDescTableMap.php +++ b/core/lib/Thelia/Model/map/ImageDescTableMap.php @@ -57,7 +57,20 @@ class ImageDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('image_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('image_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ImageDescTableMap diff --git a/core/lib/Thelia/Model/map/ImageTableMap.php b/core/lib/Thelia/Model/map/ImageTableMap.php index d53b7e180..41f571707 100644 --- a/core/lib/Thelia/Model/map/ImageTableMap.php +++ b/core/lib/Thelia/Model/map/ImageTableMap.php @@ -49,8 +49,8 @@ class ImageTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,11 +59,24 @@ class ImageTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null); - $this->addRelation('ImageDesc', 'Thelia\\Model\\ImageDesc', RelationMap::ONE_TO_MANY, array('id' => 'image_id', ), 'CASCADE', null, 'ImageDescs'); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ImageDesc', 'Thelia\\Model\\ImageDesc', RelationMap::ONE_TO_MANY, array('id' => 'image_id', ), 'CASCADE', 'RESTRICT', 'ImageDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ImageTableMap diff --git a/core/lib/Thelia/Model/map/LangTableMap.php b/core/lib/Thelia/Model/map/LangTableMap.php index f7c93fef6..ae0c57d05 100644 --- a/core/lib/Thelia/Model/map/LangTableMap.php +++ b/core/lib/Thelia/Model/map/LangTableMap.php @@ -46,9 +46,9 @@ class LangTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 100, null); $this->addColumn('CODE', 'Code', 'VARCHAR', false, 10, null); $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null); - $this->addColumn('DEFAULT_UTILITY', 'DefaultUtility', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, 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() @@ -59,4 +59,17 @@ class LangTableMap extends TableMap { } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // LangTableMap diff --git a/core/lib/Thelia/Model/map/MessageDescTableMap.php b/core/lib/Thelia/Model/map/MessageDescTableMap.php index f4b6705d4..0cc2bff7c 100644 --- a/core/lib/Thelia/Model/map/MessageDescTableMap.php +++ b/core/lib/Thelia/Model/map/MessageDescTableMap.php @@ -48,8 +48,8 @@ class MessageDescTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 45, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'VARCHAR', true, 45, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class MessageDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Message', 'Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('message_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Message', 'Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('message_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // MessageDescTableMap diff --git a/core/lib/Thelia/Model/map/MessageTableMap.php b/core/lib/Thelia/Model/map/MessageTableMap.php index 06e7c34eb..08865e42c 100644 --- a/core/lib/Thelia/Model/map/MessageTableMap.php +++ b/core/lib/Thelia/Model/map/MessageTableMap.php @@ -44,9 +44,9 @@ class MessageTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('SECURE', 'Secure', 'TINYINT', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -55,7 +55,20 @@ class MessageTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('MessageDesc', 'Thelia\\Model\\MessageDesc', RelationMap::ONE_TO_MANY, array('id' => 'message_id', ), 'CASCADE', null, 'MessageDescs'); + $this->addRelation('MessageDesc', 'Thelia\\Model\\MessageDesc', RelationMap::ONE_TO_MANY, array('id' => 'message_id', ), 'CASCADE', 'RESTRICT', 'MessageDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // MessageTableMap diff --git a/core/lib/Thelia/Model/map/ModuleDescTableMap.php b/core/lib/Thelia/Model/map/ModuleDescTableMap.php index 529bc408d..a59221f29 100644 --- a/core/lib/Thelia/Model/map/ModuleDescTableMap.php +++ b/core/lib/Thelia/Model/map/ModuleDescTableMap.php @@ -49,8 +49,8 @@ class ModuleDescTableMap extends TableMap $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); $this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class ModuleDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ModuleDescTableMap diff --git a/core/lib/Thelia/Model/map/ModuleTableMap.php b/core/lib/Thelia/Model/map/ModuleTableMap.php index 21eb422b7..44f4d8e92 100644 --- a/core/lib/Thelia/Model/map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/map/ModuleTableMap.php @@ -44,11 +44,11 @@ class ModuleTableMap extends TableMap // 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(' 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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,8 +57,21 @@ class ModuleTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'GroupModules'); - $this->addRelation('ModuleDesc', 'Thelia\\Model\\ModuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'ModuleDescs'); + $this->addRelation('ModuleDesc', 'Thelia\\Model\\ModuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ModuleDescs'); + $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ModuleTableMap diff --git a/core/lib/Thelia/Model/map/OrderAddressTableMap.php b/core/lib/Thelia/Model/map/OrderAddressTableMap.php index 91a63e855..bca5ff446 100644 --- a/core/lib/Thelia/Model/map/OrderAddressTableMap.php +++ b/core/lib/Thelia/Model/map/OrderAddressTableMap.php @@ -64,8 +64,21 @@ class OrderAddressTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('OrderRelatedByAddressInvoice', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', null, 'OrdersRelatedByAddressInvoice'); - $this->addRelation('OrderRelatedByAddressDelivery', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', null, 'OrdersRelatedByAddressDelivery'); + $this->addRelation('OrderRelatedByAddressInvoice', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressInvoice'); + $this->addRelation('OrderRelatedByAddressDelivery', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressDelivery'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderAddressTableMap diff --git a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php index 5c62094ae..069e49ea9 100644 --- a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php +++ b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php @@ -46,8 +46,8 @@ class OrderFeatureTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,7 +56,20 @@ class OrderFeatureTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', null); + $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderFeatureTableMap diff --git a/core/lib/Thelia/Model/map/OrderProductTableMap.php b/core/lib/Thelia/Model/map/OrderProductTableMap.php index 864073c5b..b673b4fbc 100644 --- a/core/lib/Thelia/Model/map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/map/OrderProductTableMap.php @@ -52,8 +52,8 @@ class OrderProductTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -62,8 +62,21 @@ class OrderProductTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', null); - $this->addRelation('OrderFeature', 'Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', null, 'OrderFeatures'); + $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('OrderFeature', 'Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderProductTableMap diff --git a/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php index 0e1d342d1..4e7cc1be4 100644 --- a/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php +++ b/core/lib/Thelia/Model/map/OrderStatusDescTableMap.php @@ -48,8 +48,8 @@ class OrderStatusDescTableMap extends TableMap $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('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,7 +58,20 @@ class OrderStatusDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'CASCADE', null); + $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderStatusDescTableMap diff --git a/core/lib/Thelia/Model/map/OrderStatusTableMap.php b/core/lib/Thelia/Model/map/OrderStatusTableMap.php index eaf2a978e..f89bca400 100644 --- a/core/lib/Thelia/Model/map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/map/OrderStatusTableMap.php @@ -44,8 +44,8 @@ class OrderStatusTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,8 +54,21 @@ class OrderStatusTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', null, 'Orders'); - $this->addRelation('OrderStatusDesc', 'Thelia\\Model\\OrderStatusDesc', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'CASCADE', null, 'OrderStatusDescs'); + $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT', 'Orders'); + $this->addRelation('OrderStatusDesc', 'Thelia\\Model\\OrderStatusDesc', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'CASCADE', 'RESTRICT', 'OrderStatusDescs'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderStatusTableMap diff --git a/core/lib/Thelia/Model/map/OrderTableMap.php b/core/lib/Thelia/Model/map/OrderTableMap.php index 12e73713d..9f50c2d54 100644 --- a/core/lib/Thelia/Model/map/OrderTableMap.php +++ b/core/lib/Thelia/Model/map/OrderTableMap.php @@ -58,8 +58,8 @@ class OrderTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -68,13 +68,26 @@ class OrderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Currency', 'Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', null); - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', null); - $this->addRelation('OrderAddressRelatedByAddressInvoice', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', null); - $this->addRelation('OrderAddressRelatedByAddressDelivery', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', null); - $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', null); - $this->addRelation('CouponOrder', 'Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', null, 'CouponOrders'); - $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', null, 'OrderProducts'); + $this->addRelation('Currency', 'Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByAddressInvoice', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByAddressDelivery', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts'); + $this->addRelation('CouponOrder', 'Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // OrderTableMap diff --git a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php index 759ac44ab..55dc912d2 100644 --- a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php +++ b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php @@ -44,6 +44,8 @@ class ProductCategoryTableMap extends TableMap // 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); // validators } // initialize() @@ -52,8 +54,21 @@ class ProductCategoryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ProductCategoryTableMap diff --git a/core/lib/Thelia/Model/map/ProductDescTableMap.php b/core/lib/Thelia/Model/map/ProductDescTableMap.php index 1e1300145..63b9582fd 100644 --- a/core/lib/Thelia/Model/map/ProductDescTableMap.php +++ b/core/lib/Thelia/Model/map/ProductDescTableMap.php @@ -49,8 +49,8 @@ class ProductDescTableMap extends TableMap $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->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATET_AT', 'UpdatetAt', 'VARCHAR', true, 45, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -59,7 +59,20 @@ class ProductDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ProductDescTableMap diff --git a/core/lib/Thelia/Model/map/ProductTableMap.php b/core/lib/Thelia/Model/map/ProductTableMap.php index 15ed9a9d3..978e6907a 100644 --- a/core/lib/Thelia/Model/map/ProductTableMap.php +++ b/core/lib/Thelia/Model/map/ProductTableMap.php @@ -50,12 +50,12 @@ class ProductTableMap extends TableMap $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('QUANTITY', 'Quantity', 'INTEGER', 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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -64,17 +64,30 @@ class ProductTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', null); - $this->addRelation('AccessoryRelatedByProductId', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'AccessorysRelatedByProductId'); - $this->addRelation('AccessoryRelatedByAccessory', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', null, 'AccessorysRelatedByAccessory'); - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ContentAssocs'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Documents'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'FeatureProds'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Images'); - $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ProductCategorys'); - $this->addRelation('ProductDesc', 'Thelia\\Model\\ProductDesc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'ProductDescs'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Rewritings'); - $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', null, 'Stocks'); + $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('ProductDesc', 'Thelia\\Model\\ProductDesc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductDescs'); + $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategorys'); + $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); + $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Stocks'); + $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); + $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Images'); + $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Documents'); + $this->addRelation('AccessoryRelatedByProductId', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessorysRelatedByProductId'); + $this->addRelation('AccessoryRelatedByAccessory', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessorysRelatedByAccessory'); + $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ProductTableMap diff --git a/core/lib/Thelia/Model/map/ResourceDescTableMap.php b/core/lib/Thelia/Model/map/ResourceDescTableMap.php index 1a0ec7b29..86d30305f 100644 --- a/core/lib/Thelia/Model/map/ResourceDescTableMap.php +++ b/core/lib/Thelia/Model/map/ResourceDescTableMap.php @@ -46,8 +46,8 @@ class ResourceDescTableMap extends TableMap $this->addForeignKey('RESOURCE_ID', 'ResourceId', 'INTEGER', 'resource', 'ID', true, null, null); $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -56,7 +56,20 @@ class ResourceDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ResourceDescTableMap diff --git a/core/lib/Thelia/Model/map/ResourceTableMap.php b/core/lib/Thelia/Model/map/ResourceTableMap.php index d2a07cfd2..fde1fc99b 100644 --- a/core/lib/Thelia/Model/map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/map/ResourceTableMap.php @@ -44,7 +44,7 @@ class ResourceTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,8 +54,21 @@ class ResourceTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', null, 'GroupResources'); - $this->addRelation('ResourceDesc', 'Thelia\\Model\\ResourceDesc', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', null, 'ResourceDescs'); + $this->addRelation('ResourceDesc', 'Thelia\\Model\\ResourceDesc', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'ResourceDescs'); + $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // ResourceTableMap diff --git a/core/lib/Thelia/Model/map/RewritingTableMap.php b/core/lib/Thelia/Model/map/RewritingTableMap.php index e895a0181..c1003c2c9 100644 --- a/core/lib/Thelia/Model/map/RewritingTableMap.php +++ b/core/lib/Thelia/Model/map/RewritingTableMap.php @@ -48,8 +48,8 @@ class RewritingTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -58,10 +58,23 @@ class RewritingTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // RewritingTableMap diff --git a/core/lib/Thelia/Model/map/StockTableMap.php b/core/lib/Thelia/Model/map/StockTableMap.php index b4aa0cab1..4e3b2b617 100644 --- a/core/lib/Thelia/Model/map/StockTableMap.php +++ b/core/lib/Thelia/Model/map/StockTableMap.php @@ -47,8 +47,8 @@ class StockTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,8 +57,21 @@ class StockTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', null); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // StockTableMap diff --git a/core/lib/Thelia/Model/map/TaxDescTableMap.php b/core/lib/Thelia/Model/map/TaxDescTableMap.php index 767a73cac..9e382f715 100644 --- a/core/lib/Thelia/Model/map/TaxDescTableMap.php +++ b/core/lib/Thelia/Model/map/TaxDescTableMap.php @@ -47,8 +47,8 @@ class TaxDescTableMap extends TableMap $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,7 +57,20 @@ class TaxDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // TaxDescTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php index e079f9f71..f4be600bb 100644 --- a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php @@ -47,8 +47,8 @@ class TaxRuleCountryTableMap extends TableMap $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', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,9 +57,22 @@ class TaxRuleCountryTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', null); - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', null); - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', null); + $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // TaxRuleCountryTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php index c47c81112..027ab27c3 100644 --- a/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleDescTableMap.php @@ -47,8 +47,8 @@ class TaxRuleDescTableMap extends TableMap $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -57,7 +57,20 @@ class TaxRuleDescTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', null); + $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // TaxRuleDescTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleTableMap.php b/core/lib/Thelia/Model/map/TaxRuleTableMap.php index def7cbb5d..8b0afad2c 100644 --- a/core/lib/Thelia/Model/map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/map/TaxRuleTableMap.php @@ -44,8 +44,8 @@ class TaxRuleTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', true, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); // validators } // initialize() @@ -54,9 +54,22 @@ class TaxRuleTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'SET NULL', null, 'Products'); - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', null, 'TaxRuleCountrys'); - $this->addRelation('TaxRuleDesc', 'Thelia\\Model\\TaxRuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', null, 'TaxRuleDescs'); + $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'SET NULL', 'RESTRICT', 'Products'); + $this->addRelation('TaxRuleDesc', 'Thelia\\Model\\TaxRuleDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleDescs'); + $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountrys'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // TaxRuleTableMap diff --git a/core/lib/Thelia/Model/map/TaxTableMap.php b/core/lib/Thelia/Model/map/TaxTableMap.php index 15c0c6a29..5a9569fec 100644 --- a/core/lib/Thelia/Model/map/TaxTableMap.php +++ b/core/lib/Thelia/Model/map/TaxTableMap.php @@ -54,8 +54,21 @@ class TaxTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('TaxDesc', 'Thelia\\Model\\TaxDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'CASCADE', null, 'TaxDescs'); - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', null, 'TaxRuleCountrys'); + $this->addRelation('TaxDesc', 'Thelia\\Model\\TaxDesc', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'CASCADE', 'RESTRICT', 'TaxDescs'); + $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', 'RESTRICT', 'TaxRuleCountrys'); } // buildRelations() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', 'disable_updated_at' => 'false', ), + ); + } // getBehaviors() + } // TaxTableMap diff --git a/core/lib/Thelia/Model/om/BaseAccessory.php b/core/lib/Thelia/Model/om/BaseAccessory.php index 091f34f0a..e8e7cfcbd 100644 --- a/core/lib/Thelia/Model/om/BaseAccessory.php +++ b/core/lib/Thelia/Model/om/BaseAccessory.php @@ -547,8 +547,19 @@ abstract class BaseAccessory extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AccessoryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AccessoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AccessoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1277,4 +1288,18 @@ abstract class BaseAccessory extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Accessory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php index b1de88d0b..9331401fa 100644 --- a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php @@ -650,4 +650,69 @@ abstract class BaseAccessoryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AccessoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AccessoryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AccessoryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AccessoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AccessoryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AccessoryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AccessoryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/om/BaseAddress.php index 75feacbd3..dd1df4e57 100644 --- a/core/lib/Thelia/Model/om/BaseAddress.php +++ b/core/lib/Thelia/Model/om/BaseAddress.php @@ -929,8 +929,19 @@ abstract class BaseAddress extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AddressPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AddressPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AddressPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1840,4 +1851,18 @@ abstract class BaseAddress extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Address The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AddressPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/om/BaseAddressQuery.php index 88ca88e7f..4cc657dde 100644 --- a/core/lib/Thelia/Model/om/BaseAddressQuery.php +++ b/core/lib/Thelia/Model/om/BaseAddressQuery.php @@ -981,4 +981,69 @@ abstract class BaseAddressQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AddressQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AddressPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AddressQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AddressPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AddressQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AddressPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AddressQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AddressPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AddressQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AddressPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AddressQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AddressPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/om/BaseAdmin.php index 4937b7d42..305b7aa8a 100644 --- a/core/lib/Thelia/Model/om/BaseAdmin.php +++ b/core/lib/Thelia/Model/om/BaseAdmin.php @@ -651,8 +651,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1588,4 +1599,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Admin The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAdminGroup.php b/core/lib/Thelia/Model/om/BaseAdminGroup.php index 9827859c4..79c00f118 100644 --- a/core/lib/Thelia/Model/om/BaseAdminGroup.php +++ b/core/lib/Thelia/Model/om/BaseAdminGroup.php @@ -511,8 +511,19 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminGroupPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1235,4 +1246,18 @@ abstract class BaseAdminGroup extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AdminGroup The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminGroupPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php index 220fb9bb5..94ae9c274 100644 --- a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php @@ -606,4 +606,69 @@ abstract class BaseAdminGroupQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminGroupPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminGroupPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AdminGroupPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AdminGroupPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AdminGroupQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AdminGroupPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAdminLog.php b/core/lib/Thelia/Model/om/BaseAdminLog.php index 189b957ba..f4885716a 100644 --- a/core/lib/Thelia/Model/om/BaseAdminLog.php +++ b/core/lib/Thelia/Model/om/BaseAdminLog.php @@ -595,8 +595,19 @@ abstract class BaseAdminLog extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminLogPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminLogPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminLogPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1208,4 +1219,18 @@ abstract class BaseAdminLog extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AdminLog The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminLogPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php index c36a80193..e2abaa1bf 100644 --- a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php @@ -513,4 +513,69 @@ abstract class BaseAdminLogQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AdminLogPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminLogPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminLogPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AdminLogPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AdminLogPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AdminLogQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AdminLogPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/om/BaseAdminQuery.php index 1d895ffcf..00f43de6a 100644 --- a/core/lib/Thelia/Model/om/BaseAdminQuery.php +++ b/core/lib/Thelia/Model/om/BaseAdminQuery.php @@ -627,4 +627,69 @@ abstract class BaseAdminQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AdminQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AdminPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AdminQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AdminQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AdminQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AdminPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AdminQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AdminPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AdminQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AdminPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseArea.php b/core/lib/Thelia/Model/om/BaseArea.php index 15f4ff9df..348cbb1dd 100644 --- a/core/lib/Thelia/Model/om/BaseArea.php +++ b/core/lib/Thelia/Model/om/BaseArea.php @@ -515,8 +515,19 @@ abstract class BaseArea extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AreaPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AreaPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AreaPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1613,4 +1624,18 @@ abstract class BaseArea extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Area The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AreaPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/om/BaseAreaQuery.php index 3c25a0bf0..9270c9e55 100644 --- a/core/lib/Thelia/Model/om/BaseAreaQuery.php +++ b/core/lib/Thelia/Model/om/BaseAreaQuery.php @@ -586,4 +586,69 @@ abstract class BaseAreaQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AreaQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AreaPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AreaQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AreaPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AreaQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AreaPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AreaQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AreaPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AreaQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AreaPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AreaQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AreaPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/om/BaseAttribute.php index e695341dc..5e31ef7b0 100644 --- a/core/lib/Thelia/Model/om/BaseAttribute.php +++ b/core/lib/Thelia/Model/om/BaseAttribute.php @@ -79,18 +79,18 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ protected $updated_at; + /** + * @var PropelObjectCollection|AttributeDesc[] Collection to store aggregation of AttributeDesc objects. + */ + protected $collAttributeDescs; + protected $collAttributeDescsPartial; + /** * @var PropelObjectCollection|AttributeAv[] Collection to store aggregation of AttributeAv objects. */ protected $collAttributeAvs; protected $collAttributeAvsPartial; - /** - * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects. - */ - protected $collAttributeCategorys; - protected $collAttributeCategorysPartial; - /** * @var PropelObjectCollection|AttributeCombination[] Collection to store aggregation of AttributeCombination objects. */ @@ -98,10 +98,10 @@ abstract class BaseAttribute extends BaseObject implements Persistent protected $collAttributeCombinationsPartial; /** - * @var PropelObjectCollection|AttributeDesc[] Collection to store aggregation of AttributeDesc objects. + * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects. */ - protected $collAttributeDescs; - protected $collAttributeDescsPartial; + protected $collAttributeCategorys; + protected $collAttributeCategorysPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -121,13 +121,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $attributeAvsScheduledForDeletion = null; + protected $attributeDescsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $attributeCategorysScheduledForDeletion = null; + protected $attributeAvsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -139,7 +139,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $attributeDescsScheduledForDeletion = null; + protected $attributeCategorysScheduledForDeletion = null; /** * Get the [id] column value. @@ -429,13 +429,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collAttributeAvs = null; + $this->collAttributeDescs = null; - $this->collAttributeCategorys = null; + $this->collAttributeAvs = null; $this->collAttributeCombinations = null; - $this->collAttributeDescs = null; + $this->collAttributeCategorys = null; } // if (deep) } @@ -509,8 +509,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -561,6 +572,23 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->resetModified(); } + if ($this->attributeDescsScheduledForDeletion !== null) { + if (!$this->attributeDescsScheduledForDeletion->isEmpty()) { + AttributeDescQuery::create() + ->filterByPrimaryKeys($this->attributeDescsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->attributeDescsScheduledForDeletion = null; + } + } + + if ($this->collAttributeDescs !== null) { + foreach ($this->collAttributeDescs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->attributeAvsScheduledForDeletion !== null) { if (!$this->attributeAvsScheduledForDeletion->isEmpty()) { AttributeAvQuery::create() @@ -578,23 +606,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - if ($this->attributeCategorysScheduledForDeletion !== null) { - if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->attributeCombinationsScheduledForDeletion !== null) { if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { AttributeCombinationQuery::create() @@ -612,17 +623,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - if ($this->attributeDescsScheduledForDeletion !== null) { - if (!$this->attributeDescsScheduledForDeletion->isEmpty()) { - AttributeDescQuery::create() - ->filterByPrimaryKeys($this->attributeDescsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->attributeCategorysScheduledForDeletion !== null) { + if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { + AttributeCategoryQuery::create() + ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->attributeDescsScheduledForDeletion = null; + $this->attributeCategorysScheduledForDeletion = null; } } - if ($this->collAttributeDescs !== null) { - foreach ($this->collAttributeDescs as $referrerFK) { + if ($this->collAttributeCategorys !== null) { + foreach ($this->collAttributeCategorys as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } @@ -789,16 +800,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent } - if ($this->collAttributeAvs !== null) { - foreach ($this->collAttributeAvs as $referrerFK) { + if ($this->collAttributeDescs !== null) { + foreach ($this->collAttributeDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { + if ($this->collAttributeAvs !== null) { + foreach ($this->collAttributeAvs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -813,8 +824,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - if ($this->collAttributeDescs !== null) { - foreach ($this->collAttributeDescs as $referrerFK) { + if ($this->collAttributeCategorys !== null) { + foreach ($this->collAttributeCategorys as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -903,17 +914,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent $keys[3] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { + if (null !== $this->collAttributeDescs) { + $result['AttributeDescs'] = $this->collAttributeDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collAttributeAvs) { $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collAttributeCategorys) { - $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collAttributeCombinations) { $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collAttributeDescs) { - $result['AttributeDescs'] = $this->collAttributeDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAttributeCategorys) { + $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1078,15 +1089,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getAttributeAvs() as $relObj) { + foreach ($this->getAttributeDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeAv($relObj->copy($deepCopy)); + $copyObj->addAttributeDesc($relObj->copy($deepCopy)); } } - foreach ($this->getAttributeCategorys() as $relObj) { + foreach ($this->getAttributeAvs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); + $copyObj->addAttributeAv($relObj->copy($deepCopy)); } } @@ -1096,9 +1107,9 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - foreach ($this->getAttributeDescs() as $relObj) { + foreach ($this->getAttributeCategorys() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeDesc($relObj->copy($deepCopy)); + $copyObj->addAttributeCategory($relObj->copy($deepCopy)); } } @@ -1163,17 +1174,224 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('AttributeDesc' == $relationName) { + $this->initAttributeDescs(); + } if ('AttributeAv' == $relationName) { $this->initAttributeAvs(); } - if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); - } if ('AttributeCombination' == $relationName) { $this->initAttributeCombinations(); } - if ('AttributeDesc' == $relationName) { + if ('AttributeCategory' == $relationName) { + $this->initAttributeCategorys(); + } + } + + /** + * Clears out the collAttributeDescs collection + * + * 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 + * @see addAttributeDescs() + */ + public function clearAttributeDescs() + { + $this->collAttributeDescs = null; // important to set this to null since that means it is uninitialized + $this->collAttributeDescsPartial = null; + } + + /** + * reset is the collAttributeDescs collection loaded partially + * + * @return void + */ + public function resetPartialAttributeDescs($v = true) + { + $this->collAttributeDescsPartial = $v; + } + + /** + * Initializes the collAttributeDescs collection. + * + * By default this just sets the collAttributeDescs collection to an empty array (like clearcollAttributeDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAttributeDescs($overrideExisting = true) + { + if (null !== $this->collAttributeDescs && !$overrideExisting) { + return; + } + $this->collAttributeDescs = new PropelObjectCollection(); + $this->collAttributeDescs->setModel('AttributeDesc'); + } + + /** + * Gets an array of AttributeDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Attribute is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|AttributeDesc[] List of AttributeDesc objects + * @throws PropelException + */ + public function getAttributeDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collAttributeDescsPartial && !$this->isNew(); + if (null === $this->collAttributeDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeDescs) { + // return empty collection + $this->initAttributeDescs(); + } else { + $collAttributeDescs = AttributeDescQuery::create(null, $criteria) + ->filterByAttribute($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collAttributeDescsPartial && count($collAttributeDescs)) { + $this->initAttributeDescs(false); + + foreach($collAttributeDescs as $obj) { + if (false == $this->collAttributeDescs->contains($obj)) { + $this->collAttributeDescs->append($obj); + } + } + + $this->collAttributeDescsPartial = true; + } + + return $collAttributeDescs; + } + + if($partial && $this->collAttributeDescs) { + foreach($this->collAttributeDescs as $obj) { + if($obj->isNew()) { + $collAttributeDescs[] = $obj; + } + } + } + + $this->collAttributeDescs = $collAttributeDescs; + $this->collAttributeDescsPartial = false; + } + } + + return $this->collAttributeDescs; + } + + /** + * Sets a collection of AttributeDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $attributeDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setAttributeDescs(PropelCollection $attributeDescs, PropelPDO $con = null) + { + $this->attributeDescsScheduledForDeletion = $this->getAttributeDescs(new Criteria(), $con)->diff($attributeDescs); + + foreach ($this->attributeDescsScheduledForDeletion as $attributeDescRemoved) { + $attributeDescRemoved->setAttribute(null); + } + + $this->collAttributeDescs = null; + foreach ($attributeDescs as $attributeDesc) { + $this->addAttributeDesc($attributeDesc); + } + + $this->collAttributeDescs = $attributeDescs; + $this->collAttributeDescsPartial = false; + } + + /** + * Returns the number of related AttributeDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related AttributeDesc objects. + * @throws PropelException + */ + public function countAttributeDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collAttributeDescsPartial && !$this->isNew(); + if (null === $this->collAttributeDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getAttributeDescs()); + } + $query = AttributeDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByAttribute($this) + ->count($con); + } + } else { + return count($this->collAttributeDescs); + } + } + + /** + * Method called to associate a AttributeDesc object to this object + * through the AttributeDesc foreign key attribute. + * + * @param AttributeDesc $l AttributeDesc + * @return Attribute The current object (for fluent API support) + */ + public function addAttributeDesc(AttributeDesc $l) + { + if ($this->collAttributeDescs === null) { $this->initAttributeDescs(); + $this->collAttributeDescsPartial = true; + } + if (!$this->collAttributeDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddAttributeDesc($l); + } + + return $this; + } + + /** + * @param AttributeDesc $attributeDesc The attributeDesc object to add. + */ + protected function doAddAttributeDesc($attributeDesc) + { + $this->collAttributeDescs[]= $attributeDesc; + $attributeDesc->setAttribute($this); + } + + /** + * @param AttributeDesc $attributeDesc The attributeDesc object to remove. + */ + public function removeAttributeDesc($attributeDesc) + { + if ($this->getAttributeDescs()->contains($attributeDesc)) { + $this->collAttributeDescs->remove($this->collAttributeDescs->search($attributeDesc)); + if (null === $this->attributeDescsScheduledForDeletion) { + $this->attributeDescsScheduledForDeletion = clone $this->collAttributeDescs; + $this->attributeDescsScheduledForDeletion->clear(); + } + $this->attributeDescsScheduledForDeletion[]= $attributeDesc; + $attributeDesc->setAttribute(null); } } @@ -1384,238 +1602,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - /** - * Clears out the collAttributeCategorys collection - * - * 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 - * @see addAttributeCategorys() - */ - public function clearAttributeCategorys() - { - $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCategorysPartial = null; - } - - /** - * reset is the collAttributeCategorys collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCategorys($v = true) - { - $this->collAttributeCategorysPartial = $v; - } - - /** - * Initializes the collAttributeCategorys collection. - * - * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCategorys($overrideExisting = true) - { - if (null !== $this->collAttributeCategorys && !$overrideExisting) { - return; - } - $this->collAttributeCategorys = new PropelObjectCollection(); - $this->collAttributeCategorys->setModel('AttributeCategory'); - } - - /** - * Gets an array of AttributeCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - * @throws PropelException - */ - public function getAttributeCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { - // return empty collection - $this->initAttributeCategorys(); - } else { - $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { - $this->initAttributeCategorys(false); - - foreach($collAttributeCategorys as $obj) { - if (false == $this->collAttributeCategorys->contains($obj)) { - $this->collAttributeCategorys->append($obj); - } - } - - $this->collAttributeCategorysPartial = true; - } - - return $collAttributeCategorys; - } - - if($partial && $this->collAttributeCategorys) { - foreach($this->collAttributeCategorys as $obj) { - if($obj->isNew()) { - $collAttributeCategorys[] = $obj; - } - } - } - - $this->collAttributeCategorys = $collAttributeCategorys; - $this->collAttributeCategorysPartial = false; - } - } - - return $this->collAttributeCategorys; - } - - /** - * Sets a collection of AttributeCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) - { - $this->attributeCategorysScheduledForDeletion = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - - foreach ($this->attributeCategorysScheduledForDeletion as $attributeCategoryRemoved) { - $attributeCategoryRemoved->setAttribute(null); - } - - $this->collAttributeCategorys = null; - foreach ($attributeCategorys as $attributeCategory) { - $this->addAttributeCategory($attributeCategory); - } - - $this->collAttributeCategorys = $attributeCategorys; - $this->collAttributeCategorysPartial = false; - } - - /** - * Returns the number of related AttributeCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCategory objects. - * @throws PropelException - */ - public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a AttributeCategory object to this object - * through the AttributeCategory foreign key attribute. - * - * @param AttributeCategory $l AttributeCategory - * @return Attribute The current object (for fluent API support) - */ - public function addAttributeCategory(AttributeCategory $l) - { - if ($this->collAttributeCategorys === null) { - $this->initAttributeCategorys(); - $this->collAttributeCategorysPartial = true; - } - if (!$this->collAttributeCategorys->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCategory($l); - } - - return $this; - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. - */ - protected function doAddAttributeCategory($attributeCategory) - { - $this->collAttributeCategorys[]= $attributeCategory; - $attributeCategory->setAttribute($this); - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - */ - public function removeAttributeCategory($attributeCategory) - { - if ($this->getAttributeCategorys()->contains($attributeCategory)) { - $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory)); - if (null === $this->attributeCategorysScheduledForDeletion) { - $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; - $this->attributeCategorysScheduledForDeletion->clear(); - } - $this->attributeCategorysScheduledForDeletion[]= $attributeCategory; - $attributeCategory->setAttribute(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Attribute is new, it will return - * an empty collection; or if this Attribute has previously - * been saved, it will retrieve related AttributeCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Attribute. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - */ - public function getAttributeCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getAttributeCategorys($query, $con); - } - /** * Clears out the collAttributeCombinations collection * @@ -1874,34 +1860,34 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * Clears out the collAttributeDescs collection + * Clears out the collAttributeCategorys collection * * 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 - * @see addAttributeDescs() + * @see addAttributeCategorys() */ - public function clearAttributeDescs() + public function clearAttributeCategorys() { - $this->collAttributeDescs = null; // important to set this to null since that means it is uninitialized - $this->collAttributeDescsPartial = null; + $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized + $this->collAttributeCategorysPartial = null; } /** - * reset is the collAttributeDescs collection loaded partially + * reset is the collAttributeCategorys collection loaded partially * * @return void */ - public function resetPartialAttributeDescs($v = true) + public function resetPartialAttributeCategorys($v = true) { - $this->collAttributeDescsPartial = $v; + $this->collAttributeCategorysPartial = $v; } /** - * Initializes the collAttributeDescs collection. + * Initializes the collAttributeCategorys collection. * - * By default this just sets the collAttributeDescs collection to an empty array (like clearcollAttributeDescs()); + * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1910,17 +1896,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @return void */ - public function initAttributeDescs($overrideExisting = true) + public function initAttributeCategorys($overrideExisting = true) { - if (null !== $this->collAttributeDescs && !$overrideExisting) { + if (null !== $this->collAttributeCategorys && !$overrideExisting) { return; } - $this->collAttributeDescs = new PropelObjectCollection(); - $this->collAttributeDescs->setModel('AttributeDesc'); + $this->collAttributeCategorys = new PropelObjectCollection(); + $this->collAttributeCategorys->setModel('AttributeCategory'); } /** - * Gets an array of AttributeDesc objects which contain a foreign key that references this object. + * Gets an array of AttributeCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1930,98 +1916,98 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeDesc[] List of AttributeDesc objects + * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects * @throws PropelException */ - public function getAttributeDescs($criteria = null, PropelPDO $con = null) + public function getAttributeCategorys($criteria = null, PropelPDO $con = null) { - $partial = $this->collAttributeDescsPartial && !$this->isNew(); - if (null === $this->collAttributeDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeDescs) { + $partial = $this->collAttributeCategorysPartial && !$this->isNew(); + if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategorys) { // return empty collection - $this->initAttributeDescs(); + $this->initAttributeCategorys(); } else { - $collAttributeDescs = AttributeDescQuery::create(null, $criteria) + $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collAttributeDescsPartial && count($collAttributeDescs)) { - $this->initAttributeDescs(false); + if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { + $this->initAttributeCategorys(false); - foreach($collAttributeDescs as $obj) { - if (false == $this->collAttributeDescs->contains($obj)) { - $this->collAttributeDescs->append($obj); + foreach($collAttributeCategorys as $obj) { + if (false == $this->collAttributeCategorys->contains($obj)) { + $this->collAttributeCategorys->append($obj); } } - $this->collAttributeDescsPartial = true; + $this->collAttributeCategorysPartial = true; } - return $collAttributeDescs; + return $collAttributeCategorys; } - if($partial && $this->collAttributeDescs) { - foreach($this->collAttributeDescs as $obj) { + if($partial && $this->collAttributeCategorys) { + foreach($this->collAttributeCategorys as $obj) { if($obj->isNew()) { - $collAttributeDescs[] = $obj; + $collAttributeCategorys[] = $obj; } } } - $this->collAttributeDescs = $collAttributeDescs; - $this->collAttributeDescsPartial = false; + $this->collAttributeCategorys = $collAttributeCategorys; + $this->collAttributeCategorysPartial = false; } } - return $this->collAttributeDescs; + return $this->collAttributeCategorys; } /** - * Sets a collection of AttributeDesc objects related by a one-to-many relationship + * Sets a collection of AttributeCategory objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param PropelCollection $attributeDescs A Propel collection. + * @param PropelCollection $attributeCategorys A Propel collection. * @param PropelPDO $con Optional connection object */ - public function setAttributeDescs(PropelCollection $attributeDescs, PropelPDO $con = null) + public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) { - $this->attributeDescsScheduledForDeletion = $this->getAttributeDescs(new Criteria(), $con)->diff($attributeDescs); + $this->attributeCategorysScheduledForDeletion = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - foreach ($this->attributeDescsScheduledForDeletion as $attributeDescRemoved) { - $attributeDescRemoved->setAttribute(null); + foreach ($this->attributeCategorysScheduledForDeletion as $attributeCategoryRemoved) { + $attributeCategoryRemoved->setAttribute(null); } - $this->collAttributeDescs = null; - foreach ($attributeDescs as $attributeDesc) { - $this->addAttributeDesc($attributeDesc); + $this->collAttributeCategorys = null; + foreach ($attributeCategorys as $attributeCategory) { + $this->addAttributeCategory($attributeCategory); } - $this->collAttributeDescs = $attributeDescs; - $this->collAttributeDescsPartial = false; + $this->collAttributeCategorys = $attributeCategorys; + $this->collAttributeCategorysPartial = false; } /** - * Returns the number of related AttributeDesc objects. + * Returns the number of related AttributeCategory objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con - * @return int Count of related AttributeDesc objects. + * @return int Count of related AttributeCategory objects. * @throws PropelException */ - public function countAttributeDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { - $partial = $this->collAttributeDescsPartial && !$this->isNew(); - if (null === $this->collAttributeDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeDescs) { + $partial = $this->collAttributeCategorysPartial && !$this->isNew(); + if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategorys) { return 0; } else { if($partial && !$criteria) { - return count($this->getAttributeDescs()); + return count($this->getAttributeCategorys()); } - $query = AttributeDescQuery::create(null, $criteria); + $query = AttributeCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2031,55 +2017,80 @@ abstract class BaseAttribute extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collAttributeDescs); + return count($this->collAttributeCategorys); } } /** - * Method called to associate a AttributeDesc object to this object - * through the AttributeDesc foreign key attribute. + * Method called to associate a AttributeCategory object to this object + * through the AttributeCategory foreign key attribute. * - * @param AttributeDesc $l AttributeDesc + * @param AttributeCategory $l AttributeCategory * @return Attribute The current object (for fluent API support) */ - public function addAttributeDesc(AttributeDesc $l) + public function addAttributeCategory(AttributeCategory $l) { - if ($this->collAttributeDescs === null) { - $this->initAttributeDescs(); - $this->collAttributeDescsPartial = true; + if ($this->collAttributeCategorys === null) { + $this->initAttributeCategorys(); + $this->collAttributeCategorysPartial = true; } - if (!$this->collAttributeDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddAttributeDesc($l); + if (!$this->collAttributeCategorys->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddAttributeCategory($l); } return $this; } /** - * @param AttributeDesc $attributeDesc The attributeDesc object to add. + * @param AttributeCategory $attributeCategory The attributeCategory object to add. */ - protected function doAddAttributeDesc($attributeDesc) + protected function doAddAttributeCategory($attributeCategory) { - $this->collAttributeDescs[]= $attributeDesc; - $attributeDesc->setAttribute($this); + $this->collAttributeCategorys[]= $attributeCategory; + $attributeCategory->setAttribute($this); } /** - * @param AttributeDesc $attributeDesc The attributeDesc object to remove. + * @param AttributeCategory $attributeCategory The attributeCategory object to remove. */ - public function removeAttributeDesc($attributeDesc) + public function removeAttributeCategory($attributeCategory) { - if ($this->getAttributeDescs()->contains($attributeDesc)) { - $this->collAttributeDescs->remove($this->collAttributeDescs->search($attributeDesc)); - if (null === $this->attributeDescsScheduledForDeletion) { - $this->attributeDescsScheduledForDeletion = clone $this->collAttributeDescs; - $this->attributeDescsScheduledForDeletion->clear(); + if ($this->getAttributeCategorys()->contains($attributeCategory)) { + $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory)); + if (null === $this->attributeCategorysScheduledForDeletion) { + $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; + $this->attributeCategorysScheduledForDeletion->clear(); } - $this->attributeDescsScheduledForDeletion[]= $attributeDesc; - $attributeDesc->setAttribute(null); + $this->attributeCategorysScheduledForDeletion[]= $attributeCategory; + $attributeCategory->setAttribute(null); } } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Attribute is new, it will return + * an empty collection; or if this Attribute has previously + * been saved, it will retrieve related AttributeCategorys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Attribute. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects + */ + public function getAttributeCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = AttributeCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getAttributeCategorys($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -2109,13 +2120,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collAttributeAvs) { - foreach ($this->collAttributeAvs as $o) { + if ($this->collAttributeDescs) { + foreach ($this->collAttributeDescs as $o) { $o->clearAllReferences($deep); } } - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { + if ($this->collAttributeAvs) { + foreach ($this->collAttributeAvs as $o) { $o->clearAllReferences($deep); } } @@ -2124,29 +2135,29 @@ abstract class BaseAttribute extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collAttributeDescs) { - foreach ($this->collAttributeDescs as $o) { + if ($this->collAttributeCategorys) { + foreach ($this->collAttributeCategorys as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collAttributeAvs instanceof PropelCollection) { - $this->collAttributeAvs->clearIterator(); - } - $this->collAttributeAvs = null; - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); - } - $this->collAttributeCategorys = null; - if ($this->collAttributeCombinations instanceof PropelCollection) { - $this->collAttributeCombinations->clearIterator(); - } - $this->collAttributeCombinations = null; if ($this->collAttributeDescs instanceof PropelCollection) { $this->collAttributeDescs->clearIterator(); } $this->collAttributeDescs = null; + if ($this->collAttributeAvs instanceof PropelCollection) { + $this->collAttributeAvs->clearIterator(); + } + $this->collAttributeAvs = null; + if ($this->collAttributeCombinations instanceof PropelCollection) { + $this->collAttributeCombinations->clearIterator(); + } + $this->collAttributeCombinations = null; + if ($this->collAttributeCategorys instanceof PropelCollection) { + $this->collAttributeCategorys->clearIterator(); + } + $this->collAttributeCategorys = null; } /** @@ -2169,4 +2180,18 @@ abstract class BaseAttribute extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Attribute The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/om/BaseAttributeAv.php index b99f10b08..c7cc116fd 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAv.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAv.php @@ -530,8 +530,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeAvPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1755,4 +1766,18 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AttributeAv The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeAvPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php index 32ecd67f7..633e9592d 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvDesc.php @@ -610,8 +610,19 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeAvDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeAvDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeAvDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseAttributeAvDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AttributeAvDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeAvDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php index 09be2e38f..31faf517d 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseAttributeAvDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributeAvDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeAvDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeAvDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributeAvDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeAvDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeAvDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeAvDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php index ee2538c78..2da19dc3e 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php @@ -681,4 +681,69 @@ abstract class BaseAttributeAvQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeAvPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeAvPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributeAvPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeAvPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeAvQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeAvPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategory.php b/core/lib/Thelia/Model/om/BaseAttributeCategory.php index 83289bb94..9c42e2082 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCategory.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCategory.php @@ -511,8 +511,19 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1235,4 +1246,18 @@ abstract class BaseAttributeCategory extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AttributeCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeCategoryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php index 69e02fdcb..c795bdddd 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php @@ -606,4 +606,69 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCategoryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCategoryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeCategoryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombination.php b/core/lib/Thelia/Model/om/BaseAttributeCombination.php index 1962f67ad..562d3adce 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombination.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombination.php @@ -564,8 +564,19 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1386,4 +1397,18 @@ abstract class BaseAttributeCombination extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AttributeCombination The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeCombinationPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php index 49bb8677d..b6baad13b 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php @@ -88,7 +88,7 @@ abstract class BaseAttributeCombinationPeer BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeId', 'combinationId', 'attributeAvId', 'createdAt', 'updatedAt', ), BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, AttributeCombinationPeer::COMBINATION_ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeCombinationPeer::CREATED_AT, AttributeCombinationPeer::UPDATED_AT, ), BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_ID', 'COMBINATION_ID', 'ATTRIBUTE_AV_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_At', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) ); @@ -103,7 +103,7 @@ abstract class BaseAttributeCombinationPeer BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeId' => 1, 'combinationId' => 2, 'attributeAvId' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID => 0, AttributeCombinationPeer::ATTRIBUTE_ID => 1, AttributeCombinationPeer::COMBINATION_ID => 2, AttributeCombinationPeer::ATTRIBUTE_AV_ID => 3, AttributeCombinationPeer::CREATED_AT => 4, AttributeCombinationPeer::UPDATED_AT => 5, ), BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_ID' => 1, 'COMBINATION_ID' => 2, 'ATTRIBUTE_AV_ID' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_At' => 5, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_at' => 5, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) ); diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php index 2d6edd41d..c9f1acb1c 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php @@ -29,14 +29,14 @@ use Thelia\Model\Combination; * @method AttributeCombinationQuery orderByCombinationId($order = Criteria::ASC) Order by the combination_id column * @method AttributeCombinationQuery orderByAttributeAvId($order = Criteria::ASC) Order by the attribute_av_id column * @method AttributeCombinationQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method AttributeCombinationQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_At column + * @method AttributeCombinationQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method AttributeCombinationQuery groupById() Group by the id column * @method AttributeCombinationQuery groupByAttributeId() Group by the attribute_id column * @method AttributeCombinationQuery groupByCombinationId() Group by the combination_id column * @method AttributeCombinationQuery groupByAttributeAvId() Group by the attribute_av_id column * @method AttributeCombinationQuery groupByCreatedAt() Group by the created_at column - * @method AttributeCombinationQuery groupByUpdatedAt() Group by the updated_At column + * @method AttributeCombinationQuery groupByUpdatedAt() Group by the updated_at column * * @method AttributeCombinationQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method AttributeCombinationQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -62,14 +62,14 @@ use Thelia\Model\Combination; * @method AttributeCombination findOneByCombinationId(int $combination_id) Return the first AttributeCombination filtered by the combination_id column * @method AttributeCombination findOneByAttributeAvId(int $attribute_av_id) Return the first AttributeCombination filtered by the attribute_av_id column * @method AttributeCombination findOneByCreatedAt(string $created_at) Return the first AttributeCombination filtered by the created_at column - * @method AttributeCombination findOneByUpdatedAt(string $updated_At) Return the first AttributeCombination filtered by the updated_At column + * @method AttributeCombination findOneByUpdatedAt(string $updated_at) Return the first AttributeCombination filtered by the updated_at column * * @method array findById(int $id) Return AttributeCombination objects filtered by the id column * @method array findByAttributeId(int $attribute_id) Return AttributeCombination objects filtered by the attribute_id column * @method array findByCombinationId(int $combination_id) Return AttributeCombination objects filtered by the combination_id column * @method array findByAttributeAvId(int $attribute_av_id) Return AttributeCombination objects filtered by the attribute_av_id column * @method array findByCreatedAt(string $created_at) Return AttributeCombination objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_At) Return AttributeCombination objects filtered by the updated_At column + * @method array findByUpdatedAt(string $updated_at) Return AttributeCombination objects filtered by the updated_at column * * @package propel.generator.Thelia.Model.om */ @@ -427,13 +427,13 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } /** - * Filter the query on the updated_At column + * Filter the query on the updated_at column * * Example usage: * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_At = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_At = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_At > '2011-03-13' + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' * * * @param mixed $updatedAt The value to use as filter. @@ -717,4 +717,69 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCombinationPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCombinationPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeCombinationQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttributeDesc.php b/core/lib/Thelia/Model/om/BaseAttributeDesc.php index 9f0247632..97fabc7bf 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeDesc.php +++ b/core/lib/Thelia/Model/om/BaseAttributeDesc.php @@ -610,8 +610,19 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseAttributeDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AttributeDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php index 421f6279c..3ce899271 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseAttributeDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributeDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributeDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseAttributePeer.php b/core/lib/Thelia/Model/om/BaseAttributePeer.php index 33e211dc0..77bab2049 100644 --- a/core/lib/Thelia/Model/om/BaseAttributePeer.php +++ b/core/lib/Thelia/Model/om/BaseAttributePeer.php @@ -381,18 +381,18 @@ abstract class BaseAttributePeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in AttributeAvPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeAvPeer::clearInstancePool(); - // Invalidate objects in AttributeCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCategoryPeer::clearInstancePool(); - // Invalidate objects in AttributeCombinationPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCombinationPeer::clearInstancePool(); // Invalidate objects in AttributeDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AttributeDescPeer::clearInstancePool(); + // Invalidate objects in AttributeAvPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeAvPeer::clearInstancePool(); + // Invalidate objects in AttributeCombinationPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCombinationPeer::clearInstancePool(); + // Invalidate objects in AttributeCategoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCategoryPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/om/BaseAttributeQuery.php index 15ca7f633..59746ca5a 100644 --- a/core/lib/Thelia/Model/om/BaseAttributeQuery.php +++ b/core/lib/Thelia/Model/om/BaseAttributeQuery.php @@ -39,21 +39,21 @@ use Thelia\Model\AttributeQuery; * @method AttributeQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method AttributeQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method AttributeQuery leftJoinAttributeDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeDesc relation + * @method AttributeQuery rightJoinAttributeDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeDesc relation + * @method AttributeQuery innerJoinAttributeDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeDesc relation + * * @method AttributeQuery leftJoinAttributeAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeAv relation * @method AttributeQuery rightJoinAttributeAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeAv relation * @method AttributeQuery innerJoinAttributeAv($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeAv relation * - * @method AttributeQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation - * @method AttributeQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation - * @method AttributeQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation - * * @method AttributeQuery leftJoinAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCombination relation * @method AttributeQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation * @method AttributeQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation * - * @method AttributeQuery leftJoinAttributeDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeDesc relation - * @method AttributeQuery rightJoinAttributeDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeDesc relation - * @method AttributeQuery innerJoinAttributeDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeDesc relation + * @method AttributeQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation + * @method AttributeQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation + * @method AttributeQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation * * @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 @@ -399,6 +399,80 @@ abstract class BaseAttributeQuery extends ModelCriteria return $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related AttributeDesc object + * + * @param AttributeDesc|PropelObjectCollection $attributeDesc 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. + */ + public function filterByAttributeDesc($attributeDesc, $comparison = null) + { + if ($attributeDesc instanceof AttributeDesc) { + return $this + ->addUsingAlias(AttributePeer::ID, $attributeDesc->getAttributeId(), $comparison); + } elseif ($attributeDesc instanceof PropelObjectCollection) { + return $this + ->useAttributeDescQuery() + ->filterByPrimaryKeys($attributeDesc->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAttributeDesc() only accepts arguments of type AttributeDesc or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the AttributeDesc relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return AttributeQuery The current query, for fluid interface + */ + public function joinAttributeDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AttributeDesc'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'AttributeDesc'); + } + + return $this; + } + + /** + * Use the AttributeDesc relation AttributeDesc object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AttributeDescQuery A secondary query class using the current class as primary query + */ + public function useAttributeDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAttributeDesc($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AttributeDesc', '\Thelia\Model\AttributeDescQuery'); + } + /** * Filter the query by a related AttributeAv object * @@ -473,80 +547,6 @@ abstract class BaseAttributeQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); } - /** - * Filter the query by a related AttributeCategory object - * - * @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. - */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) - { - if ($attributeCategory instanceof AttributeCategory) { - return $this - ->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { - return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCategory'); - } - - return $this; - } - - /** - * Use the AttributeCategory relation AttributeCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query - */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); - } - /** * Filter the query by a related AttributeCombination object * @@ -622,41 +622,41 @@ abstract class BaseAttributeQuery extends ModelCriteria } /** - * Filter the query by a related AttributeDesc object + * Filter the query by a related AttributeCategory object * - * @param AttributeDesc|PropelObjectCollection $attributeDesc the related object to use as filter + * @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. */ - public function filterByAttributeDesc($attributeDesc, $comparison = null) + public function filterByAttributeCategory($attributeCategory, $comparison = null) { - if ($attributeDesc instanceof AttributeDesc) { + if ($attributeCategory instanceof AttributeCategory) { return $this - ->addUsingAlias(AttributePeer::ID, $attributeDesc->getAttributeId(), $comparison); - } elseif ($attributeDesc instanceof PropelObjectCollection) { + ->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison); + } elseif ($attributeCategory instanceof PropelObjectCollection) { return $this - ->useAttributeDescQuery() - ->filterByPrimaryKeys($attributeDesc->getPrimaryKeys()) + ->useAttributeCategoryQuery() + ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeDesc() only accepts arguments of type AttributeDesc or PropelCollection'); + throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the AttributeDesc relation + * Adds a JOIN clause to the query using the AttributeCategory relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return AttributeQuery The current query, for fluid interface */ - public function joinAttributeDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeDesc'); + $relationMap = $tableMap->getRelation('AttributeCategory'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -671,14 +671,14 @@ abstract class BaseAttributeQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'AttributeDesc'); + $this->addJoinObject($join, 'AttributeCategory'); } return $this; } /** - * Use the AttributeDesc relation AttributeDesc object + * Use the AttributeCategory relation AttributeCategory object * * @see useQuery() * @@ -686,13 +686,13 @@ abstract class BaseAttributeQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\AttributeDescQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query */ - public function useAttributeDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinAttributeDesc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeDesc', '\Thelia\Model\AttributeDescQuery'); + ->joinAttributeCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); } /** @@ -711,4 +711,69 @@ abstract class BaseAttributeQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AttributeQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AttributePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AttributeQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AttributeQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AttributeQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AttributePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AttributeQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AttributePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AttributeQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AttributePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php index 75729a095..f91f0b645 100644 --- a/core/lib/Thelia/Model/om/BaseCategory.php +++ b/core/lib/Thelia/Model/om/BaseCategory.php @@ -105,12 +105,6 @@ abstract class BaseCategory extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects. - */ - protected $collAttributeCategorys; - protected $collAttributeCategorysPartial; - /** * @var PropelObjectCollection|CategoryDesc[] Collection to store aggregation of CategoryDesc objects. */ @@ -118,16 +112,10 @@ abstract class BaseCategory extends BaseObject implements Persistent protected $collCategoryDescsPartial; /** - * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. + * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects. */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - - /** - * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; + protected $collProductCategorys; + protected $collProductCategorysPartial; /** * @var PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects. @@ -135,6 +123,18 @@ abstract class BaseCategory extends BaseObject implements Persistent protected $collFeatureCategorys; protected $collFeatureCategorysPartial; + /** + * @var PropelObjectCollection|AttributeCategory[] Collection to store aggregation of AttributeCategory objects. + */ + protected $collAttributeCategorys; + protected $collAttributeCategorysPartial; + + /** + * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. + */ + protected $collContentAssocs; + protected $collContentAssocsPartial; + /** * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects. */ @@ -142,10 +142,10 @@ abstract class BaseCategory extends BaseObject implements Persistent protected $collImagesPartial; /** - * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects. + * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. */ - protected $collProductCategorys; - protected $collProductCategorysPartial; + protected $collDocuments; + protected $collDocumentsPartial; /** * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects. @@ -167,12 +167,6 @@ abstract class BaseCategory extends BaseObject implements Persistent */ protected $alreadyInValidation = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $attributeCategorysScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -183,13 +177,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $contentAssocsScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $documentsScheduledForDeletion = null; + protected $productCategorysScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -197,6 +185,18 @@ abstract class BaseCategory extends BaseObject implements Persistent */ protected $featureCategorysScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $attributeCategorysScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $contentAssocsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -207,7 +207,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $productCategorysScheduledForDeletion = null; + protected $documentsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -599,19 +599,19 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collAttributeCategorys = null; - $this->collCategoryDescs = null; - $this->collContentAssocs = null; - - $this->collDocuments = null; + $this->collProductCategorys = null; $this->collFeatureCategorys = null; + $this->collAttributeCategorys = null; + + $this->collContentAssocs = null; + $this->collImages = null; - $this->collProductCategorys = null; + $this->collDocuments = null; $this->collRewritings = null; @@ -687,8 +687,19 @@ abstract class BaseCategory extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -739,23 +750,6 @@ abstract class BaseCategory extends BaseObject implements Persistent $this->resetModified(); } - if ($this->attributeCategorysScheduledForDeletion !== null) { - if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->categoryDescsScheduledForDeletion !== null) { if (!$this->categoryDescsScheduledForDeletion->isEmpty()) { CategoryDescQuery::create() @@ -773,6 +767,57 @@ abstract class BaseCategory extends BaseObject implements Persistent } } + if ($this->productCategorysScheduledForDeletion !== null) { + if (!$this->productCategorysScheduledForDeletion->isEmpty()) { + ProductCategoryQuery::create() + ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productCategorysScheduledForDeletion = null; + } + } + + if ($this->collProductCategorys !== null) { + foreach ($this->collProductCategorys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->featureCategorysScheduledForDeletion !== null) { + if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { + FeatureCategoryQuery::create() + ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->featureCategorysScheduledForDeletion = null; + } + } + + if ($this->collFeatureCategorys !== null) { + foreach ($this->collFeatureCategorys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->attributeCategorysScheduledForDeletion !== null) { + if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { + AttributeCategoryQuery::create() + ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->attributeCategorysScheduledForDeletion = null; + } + } + + if ($this->collAttributeCategorys !== null) { + foreach ($this->collAttributeCategorys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->contentAssocsScheduledForDeletion !== null) { if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { @@ -791,41 +836,6 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureCategorysScheduledForDeletion !== null) { - if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureCategorysScheduledForDeletion = null; - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->imagesScheduledForDeletion !== null) { if (!$this->imagesScheduledForDeletion->isEmpty()) { foreach ($this->imagesScheduledForDeletion as $image) { @@ -844,17 +854,18 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productCategorysScheduledForDeletion = null; + if ($this->documentsScheduledForDeletion !== null) { + if (!$this->documentsScheduledForDeletion->isEmpty()) { + foreach ($this->documentsScheduledForDeletion as $document) { + // need to save related object because we set the relation to null + $document->save($con); + } + $this->documentsScheduledForDeletion = null; } } - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } @@ -1057,14 +1068,6 @@ abstract class BaseCategory extends BaseObject implements Persistent } - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collCategoryDescs !== null) { foreach ($this->collCategoryDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -1073,16 +1076,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collProductCategorys !== null) { + foreach ($this->collProductCategorys as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -1097,6 +1092,22 @@ abstract class BaseCategory extends BaseObject implements Persistent } } + if ($this->collAttributeCategorys !== null) { + foreach ($this->collAttributeCategorys as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collImages !== null) { foreach ($this->collImages as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -1105,8 +1116,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -1215,26 +1226,26 @@ abstract class BaseCategory extends BaseObject implements Persistent $keys[6] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collAttributeCategorys) { - $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCategoryDescs) { $result['CategoryDescs'] = $this->collCategoryDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProductCategorys) { + $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collFeatureCategorys) { $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collAttributeCategorys) { + $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collContentAssocs) { + $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collImages) { $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collProductCategorys) { - $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collDocuments) { + $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1420,27 +1431,15 @@ abstract class BaseCategory extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getAttributeCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); - } - } - foreach ($this->getCategoryDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryDesc($relObj->copy($deepCopy)); } } - foreach ($this->getContentAssocs() as $relObj) { + foreach ($this->getProductCategorys() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); + $copyObj->addProductCategory($relObj->copy($deepCopy)); } } @@ -1450,15 +1449,27 @@ abstract class BaseCategory extends BaseObject implements Persistent } } + foreach ($this->getAttributeCategorys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAttributeCategory($relObj->copy($deepCopy)); + } + } + + foreach ($this->getContentAssocs() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentAssoc($relObj->copy($deepCopy)); + } + } + foreach ($this->getImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addImage($relObj->copy($deepCopy)); } } - foreach ($this->getProductCategorys() as $relObj) { + foreach ($this->getDocuments() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductCategory($relObj->copy($deepCopy)); + $copyObj->addDocument($relObj->copy($deepCopy)); } } @@ -1529,32 +1540,703 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); - } if ('CategoryDesc' == $relationName) { $this->initCategoryDescs(); } - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('FeatureCategory' == $relationName) { - $this->initFeatureCategorys(); - } - if ('Image' == $relationName) { - $this->initImages(); - } if ('ProductCategory' == $relationName) { $this->initProductCategorys(); } + if ('FeatureCategory' == $relationName) { + $this->initFeatureCategorys(); + } + if ('AttributeCategory' == $relationName) { + $this->initAttributeCategorys(); + } + if ('ContentAssoc' == $relationName) { + $this->initContentAssocs(); + } + if ('Image' == $relationName) { + $this->initImages(); + } + if ('Document' == $relationName) { + $this->initDocuments(); + } if ('Rewriting' == $relationName) { $this->initRewritings(); } } + /** + * Clears out the collCategoryDescs collection + * + * 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 + * @see addCategoryDescs() + */ + public function clearCategoryDescs() + { + $this->collCategoryDescs = null; // important to set this to null since that means it is uninitialized + $this->collCategoryDescsPartial = null; + } + + /** + * reset is the collCategoryDescs collection loaded partially + * + * @return void + */ + public function resetPartialCategoryDescs($v = true) + { + $this->collCategoryDescsPartial = $v; + } + + /** + * Initializes the collCategoryDescs collection. + * + * By default this just sets the collCategoryDescs collection to an empty array (like clearcollCategoryDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryDescs($overrideExisting = true) + { + if (null !== $this->collCategoryDescs && !$overrideExisting) { + return; + } + $this->collCategoryDescs = new PropelObjectCollection(); + $this->collCategoryDescs->setModel('CategoryDesc'); + } + + /** + * Gets an array of CategoryDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Category is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|CategoryDesc[] List of CategoryDesc objects + * @throws PropelException + */ + public function getCategoryDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCategoryDescsPartial && !$this->isNew(); + if (null === $this->collCategoryDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDescs) { + // return empty collection + $this->initCategoryDescs(); + } else { + $collCategoryDescs = CategoryDescQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCategoryDescsPartial && count($collCategoryDescs)) { + $this->initCategoryDescs(false); + + foreach($collCategoryDescs as $obj) { + if (false == $this->collCategoryDescs->contains($obj)) { + $this->collCategoryDescs->append($obj); + } + } + + $this->collCategoryDescsPartial = true; + } + + return $collCategoryDescs; + } + + if($partial && $this->collCategoryDescs) { + foreach($this->collCategoryDescs as $obj) { + if($obj->isNew()) { + $collCategoryDescs[] = $obj; + } + } + } + + $this->collCategoryDescs = $collCategoryDescs; + $this->collCategoryDescsPartial = false; + } + } + + return $this->collCategoryDescs; + } + + /** + * Sets a collection of CategoryDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $categoryDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setCategoryDescs(PropelCollection $categoryDescs, PropelPDO $con = null) + { + $this->categoryDescsScheduledForDeletion = $this->getCategoryDescs(new Criteria(), $con)->diff($categoryDescs); + + foreach ($this->categoryDescsScheduledForDeletion as $categoryDescRemoved) { + $categoryDescRemoved->setCategory(null); + } + + $this->collCategoryDescs = null; + foreach ($categoryDescs as $categoryDesc) { + $this->addCategoryDesc($categoryDesc); + } + + $this->collCategoryDescs = $categoryDescs; + $this->collCategoryDescsPartial = false; + } + + /** + * Returns the number of related CategoryDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CategoryDesc objects. + * @throws PropelException + */ + public function countCategoryDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCategoryDescsPartial && !$this->isNew(); + if (null === $this->collCategoryDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getCategoryDescs()); + } + $query = CategoryDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); + } + } else { + return count($this->collCategoryDescs); + } + } + + /** + * Method called to associate a CategoryDesc object to this object + * through the CategoryDesc foreign key attribute. + * + * @param CategoryDesc $l CategoryDesc + * @return Category The current object (for fluent API support) + */ + public function addCategoryDesc(CategoryDesc $l) + { + if ($this->collCategoryDescs === null) { + $this->initCategoryDescs(); + $this->collCategoryDescsPartial = true; + } + if (!$this->collCategoryDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddCategoryDesc($l); + } + + return $this; + } + + /** + * @param CategoryDesc $categoryDesc The categoryDesc object to add. + */ + protected function doAddCategoryDesc($categoryDesc) + { + $this->collCategoryDescs[]= $categoryDesc; + $categoryDesc->setCategory($this); + } + + /** + * @param CategoryDesc $categoryDesc The categoryDesc object to remove. + */ + public function removeCategoryDesc($categoryDesc) + { + if ($this->getCategoryDescs()->contains($categoryDesc)) { + $this->collCategoryDescs->remove($this->collCategoryDescs->search($categoryDesc)); + if (null === $this->categoryDescsScheduledForDeletion) { + $this->categoryDescsScheduledForDeletion = clone $this->collCategoryDescs; + $this->categoryDescsScheduledForDeletion->clear(); + } + $this->categoryDescsScheduledForDeletion[]= $categoryDesc; + $categoryDesc->setCategory(null); + } + } + + /** + * Clears out the collProductCategorys collection + * + * 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 + * @see addProductCategorys() + */ + public function clearProductCategorys() + { + $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized + $this->collProductCategorysPartial = null; + } + + /** + * reset is the collProductCategorys collection loaded partially + * + * @return void + */ + public function resetPartialProductCategorys($v = true) + { + $this->collProductCategorysPartial = $v; + } + + /** + * Initializes the collProductCategorys collection. + * + * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductCategorys($overrideExisting = true) + { + if (null !== $this->collProductCategorys && !$overrideExisting) { + return; + } + $this->collProductCategorys = new PropelObjectCollection(); + $this->collProductCategorys->setModel('ProductCategory'); + } + + /** + * Gets an array of ProductCategory objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Category is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + * @throws PropelException + */ + public function getProductCategorys($criteria = null, PropelPDO $con = null) + { + $partial = $this->collProductCategorysPartial && !$this->isNew(); + if (null === $this->collProductCategorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategorys) { + // return empty collection + $this->initProductCategorys(); + } else { + $collProductCategorys = ProductCategoryQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { + $this->initProductCategorys(false); + + foreach($collProductCategorys as $obj) { + if (false == $this->collProductCategorys->contains($obj)) { + $this->collProductCategorys->append($obj); + } + } + + $this->collProductCategorysPartial = true; + } + + return $collProductCategorys; + } + + if($partial && $this->collProductCategorys) { + foreach($this->collProductCategorys as $obj) { + if($obj->isNew()) { + $collProductCategorys[] = $obj; + } + } + } + + $this->collProductCategorys = $collProductCategorys; + $this->collProductCategorysPartial = false; + } + } + + return $this->collProductCategorys; + } + + /** + * Sets a collection of ProductCategory objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $productCategorys A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) + { + $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + + foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { + $productCategoryRemoved->setCategory(null); + } + + $this->collProductCategorys = null; + foreach ($productCategorys as $productCategory) { + $this->addProductCategory($productCategory); + } + + $this->collProductCategorys = $productCategorys; + $this->collProductCategorysPartial = false; + } + + /** + * Returns the number of related ProductCategory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ProductCategory objects. + * @throws PropelException + */ + public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collProductCategorysPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a ProductCategory object to this object + * through the ProductCategory foreign key attribute. + * + * @param ProductCategory $l ProductCategory + * @return Category The current object (for fluent API support) + */ + public function addProductCategory(ProductCategory $l) + { + if ($this->collProductCategorys === null) { + $this->initProductCategorys(); + $this->collProductCategorysPartial = true; + } + if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddProductCategory($l); + } + + return $this; + } + + /** + * @param ProductCategory $productCategory The productCategory object to add. + */ + protected function doAddProductCategory($productCategory) + { + $this->collProductCategorys[]= $productCategory; + $productCategory->setCategory($this); + } + + /** + * @param ProductCategory $productCategory The productCategory object to remove. + */ + public function removeProductCategory($productCategory) + { + if ($this->getProductCategorys()->contains($productCategory)) { + $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); + if (null === $this->productCategorysScheduledForDeletion) { + $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; + $this->productCategorysScheduledForDeletion->clear(); + } + $this->productCategorysScheduledForDeletion[]= $productCategory; + $productCategory->setCategory(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related ProductCategorys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + */ + public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ProductCategoryQuery::create(null, $criteria); + $query->joinWith('Product', $join_behavior); + + return $this->getProductCategorys($query, $con); + } + + /** + * Clears out the collFeatureCategorys collection + * + * 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 + * @see addFeatureCategorys() + */ + public function clearFeatureCategorys() + { + $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized + $this->collFeatureCategorysPartial = null; + } + + /** + * reset is the collFeatureCategorys collection loaded partially + * + * @return void + */ + public function resetPartialFeatureCategorys($v = true) + { + $this->collFeatureCategorysPartial = $v; + } + + /** + * Initializes the collFeatureCategorys collection. + * + * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFeatureCategorys($overrideExisting = true) + { + if (null !== $this->collFeatureCategorys && !$overrideExisting) { + return; + } + $this->collFeatureCategorys = new PropelObjectCollection(); + $this->collFeatureCategorys->setModel('FeatureCategory'); + } + + /** + * Gets an array of FeatureCategory objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Category is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects + * @throws PropelException + */ + public function getFeatureCategorys($criteria = null, PropelPDO $con = null) + { + $partial = $this->collFeatureCategorysPartial && !$this->isNew(); + if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureCategorys) { + // return empty collection + $this->initFeatureCategorys(); + } else { + $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { + $this->initFeatureCategorys(false); + + foreach($collFeatureCategorys as $obj) { + if (false == $this->collFeatureCategorys->contains($obj)) { + $this->collFeatureCategorys->append($obj); + } + } + + $this->collFeatureCategorysPartial = true; + } + + return $collFeatureCategorys; + } + + if($partial && $this->collFeatureCategorys) { + foreach($this->collFeatureCategorys as $obj) { + if($obj->isNew()) { + $collFeatureCategorys[] = $obj; + } + } + } + + $this->collFeatureCategorys = $collFeatureCategorys; + $this->collFeatureCategorysPartial = false; + } + } + + return $this->collFeatureCategorys; + } + + /** + * Sets a collection of FeatureCategory objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $featureCategorys A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) + { + $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); + + foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) { + $featureCategoryRemoved->setCategory(null); + } + + $this->collFeatureCategorys = null; + foreach ($featureCategorys as $featureCategory) { + $this->addFeatureCategory($featureCategory); + } + + $this->collFeatureCategorys = $featureCategorys; + $this->collFeatureCategorysPartial = false; + } + + /** + * Returns the number of related FeatureCategory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related FeatureCategory objects. + * @throws PropelException + */ + public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collFeatureCategorysPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a FeatureCategory object to this object + * through the FeatureCategory foreign key attribute. + * + * @param FeatureCategory $l FeatureCategory + * @return Category The current object (for fluent API support) + */ + public function addFeatureCategory(FeatureCategory $l) + { + if ($this->collFeatureCategorys === null) { + $this->initFeatureCategorys(); + $this->collFeatureCategorysPartial = true; + } + if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddFeatureCategory($l); + } + + return $this; + } + + /** + * @param FeatureCategory $featureCategory The featureCategory object to add. + */ + protected function doAddFeatureCategory($featureCategory) + { + $this->collFeatureCategorys[]= $featureCategory; + $featureCategory->setCategory($this); + } + + /** + * @param FeatureCategory $featureCategory The featureCategory object to remove. + */ + public function removeFeatureCategory($featureCategory) + { + if ($this->getFeatureCategorys()->contains($featureCategory)) { + $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory)); + if (null === $this->featureCategorysScheduledForDeletion) { + $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; + $this->featureCategorysScheduledForDeletion->clear(); + } + $this->featureCategorysScheduledForDeletion[]= $featureCategory; + $featureCategory->setCategory(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related FeatureCategorys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects + */ + public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = FeatureCategoryQuery::create(null, $criteria); + $query->joinWith('Feature', $join_behavior); + + return $this->getFeatureCategorys($query, $con); + } + /** * Clears out the collAttributeCategorys collection * @@ -1787,213 +2469,6 @@ abstract class BaseCategory extends BaseObject implements Persistent return $this->getAttributeCategorys($query, $con); } - /** - * Clears out the collCategoryDescs collection - * - * 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 - * @see addCategoryDescs() - */ - public function clearCategoryDescs() - { - $this->collCategoryDescs = null; // important to set this to null since that means it is uninitialized - $this->collCategoryDescsPartial = null; - } - - /** - * reset is the collCategoryDescs collection loaded partially - * - * @return void - */ - public function resetPartialCategoryDescs($v = true) - { - $this->collCategoryDescsPartial = $v; - } - - /** - * Initializes the collCategoryDescs collection. - * - * By default this just sets the collCategoryDescs collection to an empty array (like clearcollCategoryDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCategoryDescs($overrideExisting = true) - { - if (null !== $this->collCategoryDescs && !$overrideExisting) { - return; - } - $this->collCategoryDescs = new PropelObjectCollection(); - $this->collCategoryDescs->setModel('CategoryDesc'); - } - - /** - * Gets an array of CategoryDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CategoryDesc[] List of CategoryDesc objects - * @throws PropelException - */ - public function getCategoryDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCategoryDescsPartial && !$this->isNew(); - if (null === $this->collCategoryDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCategoryDescs) { - // return empty collection - $this->initCategoryDescs(); - } else { - $collCategoryDescs = CategoryDescQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCategoryDescsPartial && count($collCategoryDescs)) { - $this->initCategoryDescs(false); - - foreach($collCategoryDescs as $obj) { - if (false == $this->collCategoryDescs->contains($obj)) { - $this->collCategoryDescs->append($obj); - } - } - - $this->collCategoryDescsPartial = true; - } - - return $collCategoryDescs; - } - - if($partial && $this->collCategoryDescs) { - foreach($this->collCategoryDescs as $obj) { - if($obj->isNew()) { - $collCategoryDescs[] = $obj; - } - } - } - - $this->collCategoryDescs = $collCategoryDescs; - $this->collCategoryDescsPartial = false; - } - } - - return $this->collCategoryDescs; - } - - /** - * Sets a collection of CategoryDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $categoryDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setCategoryDescs(PropelCollection $categoryDescs, PropelPDO $con = null) - { - $this->categoryDescsScheduledForDeletion = $this->getCategoryDescs(new Criteria(), $con)->diff($categoryDescs); - - foreach ($this->categoryDescsScheduledForDeletion as $categoryDescRemoved) { - $categoryDescRemoved->setCategory(null); - } - - $this->collCategoryDescs = null; - foreach ($categoryDescs as $categoryDesc) { - $this->addCategoryDesc($categoryDesc); - } - - $this->collCategoryDescs = $categoryDescs; - $this->collCategoryDescsPartial = false; - } - - /** - * Returns the number of related CategoryDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CategoryDesc objects. - * @throws PropelException - */ - public function countCategoryDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCategoryDescsPartial && !$this->isNew(); - if (null === $this->collCategoryDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCategoryDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getCategoryDescs()); - } - $query = CategoryDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collCategoryDescs); - } - } - - /** - * Method called to associate a CategoryDesc object to this object - * through the CategoryDesc foreign key attribute. - * - * @param CategoryDesc $l CategoryDesc - * @return Category The current object (for fluent API support) - */ - public function addCategoryDesc(CategoryDesc $l) - { - if ($this->collCategoryDescs === null) { - $this->initCategoryDescs(); - $this->collCategoryDescsPartial = true; - } - if (!$this->collCategoryDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddCategoryDesc($l); - } - - return $this; - } - - /** - * @param CategoryDesc $categoryDesc The categoryDesc object to add. - */ - protected function doAddCategoryDesc($categoryDesc) - { - $this->collCategoryDescs[]= $categoryDesc; - $categoryDesc->setCategory($this); - } - - /** - * @param CategoryDesc $categoryDesc The categoryDesc object to remove. - */ - public function removeCategoryDesc($categoryDesc) - { - if ($this->getCategoryDescs()->contains($categoryDesc)) { - $this->collCategoryDescs->remove($this->collCategoryDescs->search($categoryDesc)); - if (null === $this->categoryDescsScheduledForDeletion) { - $this->categoryDescsScheduledForDeletion = clone $this->collCategoryDescs; - $this->categoryDescsScheduledForDeletion->clear(); - } - $this->categoryDescsScheduledForDeletion[]= $categoryDesc; - $categoryDesc->setCategory(null); - } - } - /** * Clears out the collContentAssocs collection * @@ -2251,520 +2726,6 @@ abstract class BaseCategory extends BaseObject implements Persistent return $this->getContentAssocs($query, $con); } - /** - * Clears out the collDocuments collection - * - * 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 - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); - - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { - $documentRemoved->setCategory(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Category The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setCategory($this); - } - - /** - * @param Document $document The document object to remove. - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setCategory(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collFeatureCategorys collection - * - * 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 - * @see addFeatureCategorys() - */ - public function clearFeatureCategorys() - { - $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized - $this->collFeatureCategorysPartial = null; - } - - /** - * reset is the collFeatureCategorys collection loaded partially - * - * @return void - */ - public function resetPartialFeatureCategorys($v = true) - { - $this->collFeatureCategorysPartial = $v; - } - - /** - * Initializes the collFeatureCategorys collection. - * - * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureCategorys($overrideExisting = true) - { - if (null !== $this->collFeatureCategorys && !$overrideExisting) { - return; - } - $this->collFeatureCategorys = new PropelObjectCollection(); - $this->collFeatureCategorys->setModel('FeatureCategory'); - } - - /** - * Gets an array of FeatureCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - * @throws PropelException - */ - public function getFeatureCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { - // return empty collection - $this->initFeatureCategorys(); - } else { - $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { - $this->initFeatureCategorys(false); - - foreach($collFeatureCategorys as $obj) { - if (false == $this->collFeatureCategorys->contains($obj)) { - $this->collFeatureCategorys->append($obj); - } - } - - $this->collFeatureCategorysPartial = true; - } - - return $collFeatureCategorys; - } - - if($partial && $this->collFeatureCategorys) { - foreach($this->collFeatureCategorys as $obj) { - if($obj->isNew()) { - $collFeatureCategorys[] = $obj; - } - } - } - - $this->collFeatureCategorys = $collFeatureCategorys; - $this->collFeatureCategorysPartial = false; - } - } - - return $this->collFeatureCategorys; - } - - /** - * Sets a collection of FeatureCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) - { - $this->featureCategorysScheduledForDeletion = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); - - foreach ($this->featureCategorysScheduledForDeletion as $featureCategoryRemoved) { - $featureCategoryRemoved->setCategory(null); - } - - $this->collFeatureCategorys = null; - foreach ($featureCategorys as $featureCategory) { - $this->addFeatureCategory($featureCategory); - } - - $this->collFeatureCategorys = $featureCategorys; - $this->collFeatureCategorysPartial = false; - } - - /** - * Returns the number of related FeatureCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureCategory objects. - * @throws PropelException - */ - public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a FeatureCategory object to this object - * through the FeatureCategory foreign key attribute. - * - * @param FeatureCategory $l FeatureCategory - * @return Category The current object (for fluent API support) - */ - public function addFeatureCategory(FeatureCategory $l) - { - if ($this->collFeatureCategorys === null) { - $this->initFeatureCategorys(); - $this->collFeatureCategorysPartial = true; - } - if (!$this->collFeatureCategorys->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddFeatureCategory($l); - } - - return $this; - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to add. - */ - protected function doAddFeatureCategory($featureCategory) - { - $this->collFeatureCategorys[]= $featureCategory; - $featureCategory->setCategory($this); - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - */ - public function removeFeatureCategory($featureCategory) - { - if ($this->getFeatureCategorys()->contains($featureCategory)) { - $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory)); - if (null === $this->featureCategorysScheduledForDeletion) { - $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; - $this->featureCategorysScheduledForDeletion->clear(); - } - $this->featureCategorysScheduledForDeletion[]= $featureCategory; - $featureCategory->setCategory(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related FeatureCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - */ - public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); - - return $this->getFeatureCategorys($query, $con); - } - /** * Clears out the collImages collection * @@ -3048,34 +3009,34 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Clears out the collProductCategorys collection + * Clears out the collDocuments collection * * 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 - * @see addProductCategorys() + * @see addDocuments() */ - public function clearProductCategorys() + public function clearDocuments() { - $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized - $this->collProductCategorysPartial = null; + $this->collDocuments = null; // important to set this to null since that means it is uninitialized + $this->collDocumentsPartial = null; } /** - * reset is the collProductCategorys collection loaded partially + * reset is the collDocuments collection loaded partially * * @return void */ - public function resetPartialProductCategorys($v = true) + public function resetPartialDocuments($v = true) { - $this->collProductCategorysPartial = $v; + $this->collDocumentsPartial = $v; } /** - * Initializes the collProductCategorys collection. + * Initializes the collDocuments collection. * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); + * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -3084,17 +3045,17 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @return void */ - public function initProductCategorys($overrideExisting = true) + public function initDocuments($overrideExisting = true) { - if (null !== $this->collProductCategorys && !$overrideExisting) { + if (null !== $this->collDocuments && !$overrideExisting) { return; } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); + $this->collDocuments = new PropelObjectCollection(); + $this->collDocuments->setModel('Document'); } /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. + * Gets an array of Document objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -3104,98 +3065,98 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + * @return PropelObjectCollection|Document[] List of Document objects * @throws PropelException */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) + public function getDocuments($criteria = null, PropelPDO $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collDocumentsPartial && !$this->isNew(); + if (null === $this->collDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collDocuments) { // return empty collection - $this->initProductCategorys(); + $this->initDocuments(); } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) + $collDocuments = DocumentQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); + if (false !== $this->collDocumentsPartial && count($collDocuments)) { + $this->initDocuments(false); - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); + foreach($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); } } - $this->collProductCategorysPartial = true; + $this->collDocumentsPartial = true; } - return $collProductCategorys; + return $collDocuments; } - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { + if($partial && $this->collDocuments) { + foreach($this->collDocuments as $obj) { if($obj->isNew()) { - $collProductCategorys[] = $obj; + $collDocuments[] = $obj; } } } - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; + $this->collDocuments = $collDocuments; + $this->collDocumentsPartial = false; } } - return $this->collProductCategorys; + return $this->collDocuments; } /** - * Sets a collection of ProductCategory objects related by a one-to-many relationship + * Sets a collection of Document objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param PropelCollection $productCategorys A Propel collection. + * @param PropelCollection $documents A Propel collection. * @param PropelPDO $con Optional connection object */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) + public function setDocuments(PropelCollection $documents, PropelPDO $con = null) { - $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); - foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { - $productCategoryRemoved->setCategory(null); + foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $documentRemoved->setCategory(null); } - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { - $this->addProductCategory($productCategory); + $this->collDocuments = null; + foreach ($documents as $document) { + $this->addDocument($document); } - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; + $this->collDocuments = $documents; + $this->collDocumentsPartial = false; } /** - * Returns the number of related ProductCategory objects. + * Returns the number of related Document objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con - * @return int Count of related ProductCategory objects. + * @return int Count of related Document objects. * @throws PropelException */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collDocumentsPartial && !$this->isNew(); + if (null === $this->collDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collDocuments) { return 0; } else { if($partial && !$criteria) { - return count($this->getProductCategorys()); + return count($this->getDocuments()); } - $query = ProductCategoryQuery::create(null, $criteria); + $query = DocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3205,52 +3166,52 @@ abstract class BaseCategory extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collProductCategorys); + return count($this->collDocuments); } } /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. + * Method called to associate a Document object to this object + * through the Document foreign key attribute. * - * @param ProductCategory $l ProductCategory + * @param Document $l Document * @return Category The current object (for fluent API support) */ - public function addProductCategory(ProductCategory $l) + public function addDocument(Document $l) { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; + if ($this->collDocuments === null) { + $this->initDocuments(); + $this->collDocumentsPartial = true; } - if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddProductCategory($l); + if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddDocument($l); } return $this; } /** - * @param ProductCategory $productCategory The productCategory object to add. + * @param Document $document The document object to add. */ - protected function doAddProductCategory($productCategory) + protected function doAddDocument($document) { - $this->collProductCategorys[]= $productCategory; - $productCategory->setCategory($this); + $this->collDocuments[]= $document; + $document->setCategory($this); } /** - * @param ProductCategory $productCategory The productCategory object to remove. + * @param Document $document The document object to remove. */ - public function removeProductCategory($productCategory) + public function removeDocument($document) { - if ($this->getProductCategorys()->contains($productCategory)) { - $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); - if (null === $this->productCategorysScheduledForDeletion) { - $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; - $this->productCategorysScheduledForDeletion->clear(); + if ($this->getDocuments()->contains($document)) { + $this->collDocuments->remove($this->collDocuments->search($document)); + if (null === $this->documentsScheduledForDeletion) { + $this->documentsScheduledForDeletion = clone $this->collDocuments; + $this->documentsScheduledForDeletion->clear(); } - $this->productCategorysScheduledForDeletion[]= $productCategory; - $productCategory->setCategory(null); + $this->documentsScheduledForDeletion[]= $document; + $document->setCategory(null); } } @@ -3260,7 +3221,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * an identical criteria, it returns the collection. * Otherwise if this Category is new, it will return * an empty collection; or if this Category has previously - * been saved, it will retrieve related ProductCategorys from storage. + * been saved, it will retrieve related Documents from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -3269,14 +3230,64 @@ abstract class BaseCategory extends BaseObject implements Persistent * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + * @return PropelObjectCollection|Document[] List of Document objects */ - public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { - $query = ProductCategoryQuery::create(null, $criteria); + $query = DocumentQuery::create(null, $criteria); $query->joinWith('Product', $join_behavior); - return $this->getProductCategorys($query, $con); + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Category is new, it will return + * an empty collection; or if this Category has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Category. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $join_behavior); + + return $this->getDocuments($query, $con); } /** @@ -3593,23 +3604,13 @@ abstract class BaseCategory extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collCategoryDescs) { foreach ($this->collCategoryDescs as $o) { $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { + if ($this->collProductCategorys) { + foreach ($this->collProductCategorys as $o) { $o->clearAllReferences($deep); } } @@ -3618,13 +3619,23 @@ abstract class BaseCategory extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->collAttributeCategorys) { + foreach ($this->collAttributeCategorys as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collContentAssocs) { + foreach ($this->collContentAssocs as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collImages) { foreach ($this->collImages as $o) { $o->clearAllReferences($deep); } } - if ($this->collProductCategorys) { - foreach ($this->collProductCategorys as $o) { + if ($this->collDocuments) { + foreach ($this->collDocuments as $o) { $o->clearAllReferences($deep); } } @@ -3635,34 +3646,34 @@ abstract class BaseCategory extends BaseObject implements Persistent } } // if ($deep) - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); - } - $this->collAttributeCategorys = null; if ($this->collCategoryDescs instanceof PropelCollection) { $this->collCategoryDescs->clearIterator(); } $this->collCategoryDescs = null; - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); - } - $this->collFeatureCategorys = null; - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; if ($this->collProductCategorys instanceof PropelCollection) { $this->collProductCategorys->clearIterator(); } $this->collProductCategorys = null; + if ($this->collFeatureCategorys instanceof PropelCollection) { + $this->collFeatureCategorys->clearIterator(); + } + $this->collFeatureCategorys = null; + if ($this->collAttributeCategorys instanceof PropelCollection) { + $this->collAttributeCategorys->clearIterator(); + } + $this->collAttributeCategorys = null; + if ($this->collContentAssocs instanceof PropelCollection) { + $this->collContentAssocs->clearIterator(); + } + $this->collContentAssocs = null; + if ($this->collImages instanceof PropelCollection) { + $this->collImages->clearIterator(); + } + $this->collImages = null; + if ($this->collDocuments instanceof PropelCollection) { + $this->collDocuments->clearIterator(); + } + $this->collDocuments = null; if ($this->collRewritings instanceof PropelCollection) { $this->collRewritings->clearIterator(); } @@ -3689,4 +3700,18 @@ abstract class BaseCategory extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Category The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCategoryDesc.php b/core/lib/Thelia/Model/om/BaseCategoryDesc.php index 4b24dc079..ee2d8a71f 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryDesc.php +++ b/core/lib/Thelia/Model/om/BaseCategoryDesc.php @@ -648,8 +648,19 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1372,4 +1383,18 @@ abstract class BaseCategoryDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CategoryDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php index 7472e3527..a2699bfb2 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseCategoryDescQuery.php @@ -643,4 +643,69 @@ abstract class BaseCategoryDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CategoryDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php index cda44319d..024425bf7 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseCategoryPeer.php @@ -400,27 +400,27 @@ abstract class BaseCategoryPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in AttributeCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCategoryPeer::clearInstancePool(); // Invalidate objects in CategoryDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CategoryDescPeer::clearInstancePool(); - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in FeatureCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureCategoryPeer::clearInstancePool(); - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); // Invalidate objects in ProductCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductCategoryPeer::clearInstancePool(); + // Invalidate objects in FeatureCategoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureCategoryPeer::clearInstancePool(); + // Invalidate objects in AttributeCategoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCategoryPeer::clearInstancePool(); + // Invalidate objects in ContentAssocPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentAssocPeer::clearInstancePool(); + // Invalidate objects in ImagePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ImagePeer::clearInstancePool(); + // Invalidate objects in DocumentPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + DocumentPeer::clearInstancePool(); // Invalidate objects in RewritingPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RewritingPeer::clearInstancePool(); diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php index fdd8e09ee..ecd750e09 100644 --- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseCategoryQuery.php @@ -49,33 +49,33 @@ use Thelia\Model\Rewriting; * @method CategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method CategoryQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation - * @method CategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation - * @method CategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation - * * @method CategoryQuery leftJoinCategoryDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryDesc relation * @method CategoryQuery rightJoinCategoryDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryDesc relation * @method CategoryQuery innerJoinCategoryDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryDesc relation * - * @method CategoryQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method CategoryQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method CategoryQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * - * @method CategoryQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method CategoryQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method CategoryQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * @method CategoryQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation + * @method CategoryQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation + * @method CategoryQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation * * @method CategoryQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation * @method CategoryQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation * @method CategoryQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation * + * @method CategoryQuery leftJoinAttributeCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCategory relation + * @method CategoryQuery rightJoinAttributeCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCategory relation + * @method CategoryQuery innerJoinAttributeCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCategory relation + * + * @method CategoryQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation + * @method CategoryQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation + * @method CategoryQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation + * * @method CategoryQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation * @method CategoryQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation * @method CategoryQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation * - * @method CategoryQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation - * @method CategoryQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation - * @method CategoryQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation + * @method CategoryQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation + * @method CategoryQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation + * @method CategoryQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation * * @method CategoryQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method CategoryQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation @@ -542,80 +542,6 @@ abstract class BaseCategoryQuery extends ModelCriteria return $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related AttributeCategory object - * - * @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. - */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) - { - if ($attributeCategory instanceof AttributeCategory) { - return $this - ->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { - return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCategory'); - } - - return $this; - } - - /** - * Use the AttributeCategory relation AttributeCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query - */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); - } - /** * Filter the query by a related CategoryDesc object * @@ -691,41 +617,41 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related ContentAssoc object + * Filter the query by a related ProductCategory object * - * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter + * @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. */ - public function filterByContentAssoc($contentAssoc, $comparison = null) + public function filterByProductCategory($productCategory, $comparison = null) { - if ($contentAssoc instanceof ContentAssoc) { + if ($productCategory instanceof ProductCategory) { return $this - ->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison); + } elseif ($productCategory instanceof PropelObjectCollection) { return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) + ->useProductCategoryQuery() + ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the ContentAssoc relation + * Adds a JOIN clause to the query using the ProductCategory relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return CategoryQuery The current query, for fluid interface */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); + $relationMap = $tableMap->getRelation('ProductCategory'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -740,14 +666,14 @@ abstract class BaseCategoryQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'ContentAssoc'); + $this->addJoinObject($join, 'ProductCategory'); } return $this; } /** - * Use the ContentAssoc relation ContentAssoc object + * Use the ProductCategory relation ProductCategory object * * @see useQuery() * @@ -755,87 +681,13 @@ abstract class BaseCategoryQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - - /** - * Filter the query by a related Document object - * - * @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. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + ->joinProductCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); } /** @@ -912,6 +764,154 @@ abstract class BaseCategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); } + /** + * Filter the query by a related AttributeCategory object + * + * @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. + */ + public function filterByAttributeCategory($attributeCategory, $comparison = null) + { + if ($attributeCategory instanceof AttributeCategory) { + return $this + ->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison); + } elseif ($attributeCategory instanceof PropelObjectCollection) { + return $this + ->useAttributeCategoryQuery() + ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the AttributeCategory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CategoryQuery The current query, for fluid interface + */ + public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AttributeCategory'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'AttributeCategory'); + } + + return $this; + } + + /** + * Use the AttributeCategory relation AttributeCategory object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query + */ + public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAttributeCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); + } + + /** + * Filter the query by a related ContentAssoc object + * + * @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. + */ + public function filterByContentAssoc($contentAssoc, $comparison = null) + { + if ($contentAssoc instanceof ContentAssoc) { + return $this + ->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison); + } elseif ($contentAssoc instanceof PropelObjectCollection) { + return $this + ->useContentAssocQuery() + ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentAssoc relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CategoryQuery The current query, for fluid interface + */ + public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentAssoc'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentAssoc'); + } + + return $this; + } + + /** + * Use the ContentAssoc relation ContentAssoc object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query + */ + public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinContentAssoc($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); + } + /** * Filter the query by a related Image object * @@ -987,41 +987,41 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related ProductCategory object + * Filter the query by a related Document object * - * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter + * @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. */ - public function filterByProductCategory($productCategory, $comparison = null) + public function filterByDocument($document, $comparison = null) { - if ($productCategory instanceof ProductCategory) { + if ($document instanceof Document) { return $this - ->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison); + } elseif ($document instanceof PropelObjectCollection) { return $this - ->useProductCategoryQuery() - ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) + ->useDocumentQuery() + ->filterByPrimaryKeys($document->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the ProductCategory relation + * Adds a JOIN clause to the query using the Document relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return CategoryQuery The current query, for fluid interface */ - public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductCategory'); + $relationMap = $tableMap->getRelation('Document'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1036,14 +1036,14 @@ abstract class BaseCategoryQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'ProductCategory'); + $this->addJoinObject($join, 'Document'); } return $this; } /** - * Use the ProductCategory relation ProductCategory object + * Use the Document relation Document object * * @see useQuery() * @@ -1051,13 +1051,13 @@ abstract class BaseCategoryQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query */ - public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this - ->joinProductCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); + ->joinDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); } /** @@ -1150,4 +1150,69 @@ abstract class BaseCategoryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CategoryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CategoryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CategoryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CategoryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCombination.php b/core/lib/Thelia/Model/om/BaseCombination.php index c692e5cdc..d433f1534 100644 --- a/core/lib/Thelia/Model/om/BaseCombination.php +++ b/core/lib/Thelia/Model/om/BaseCombination.php @@ -477,8 +477,19 @@ abstract class BaseCombination extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CombinationPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CombinationPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CombinationPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1632,4 +1643,18 @@ abstract class BaseCombination extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Combination The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CombinationPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/om/BaseCombinationQuery.php index a1e4e3d5f..74cd3f3ca 100644 --- a/core/lib/Thelia/Model/om/BaseCombinationQuery.php +++ b/core/lib/Thelia/Model/om/BaseCombinationQuery.php @@ -541,4 +541,69 @@ abstract class BaseCombinationQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CombinationQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CombinationPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CombinationPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CombinationPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CombinationQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CombinationPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CombinationQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CombinationPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CombinationQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CombinationPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/om/BaseConfig.php index 5bb82ad08..e3b0471c4 100644 --- a/core/lib/Thelia/Model/om/BaseConfig.php +++ b/core/lib/Thelia/Model/om/BaseConfig.php @@ -68,11 +68,11 @@ abstract class BaseConfig extends BaseObject implements Persistent protected $value; /** - * The value for the secure field. + * The value for the secured field. * Note: this column has a database default value of: 1 * @var int */ - protected $secure; + protected $secured; /** * The value for the hidden field. @@ -127,7 +127,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->secure = 1; + $this->secured = 1; $this->hidden = 1; } @@ -172,13 +172,13 @@ abstract class BaseConfig extends BaseObject implements Persistent } /** - * Get the [secure] column value. + * Get the [secured] column value. * * @return int */ - public function getSecure() + public function getSecured() { - return $this->secure; + return $this->secured; } /** @@ -329,25 +329,25 @@ abstract class BaseConfig extends BaseObject implements Persistent } // setValue() /** - * Set the value of [secure] column. + * Set the value of [secured] column. * * @param int $v new value * @return Config The current object (for fluent API support) */ - public function setSecure($v) + public function setSecured($v) { if ($v !== null) { $v = (int) $v; } - if ($this->secure !== $v) { - $this->secure = $v; - $this->modifiedColumns[] = ConfigPeer::SECURE; + if ($this->secured !== $v) { + $this->secured = $v; + $this->modifiedColumns[] = ConfigPeer::SECURED; } return $this; - } // setSecure() + } // setSecured() /** * Set the value of [hidden] column. @@ -426,7 +426,7 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->secure !== 1) { + if ($this->secured !== 1) { return false; } @@ -459,7 +459,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->value = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->secure = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->secured = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; $this->hidden = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; @@ -607,8 +607,19 @@ abstract class BaseConfig extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ConfigPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ConfigPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ConfigPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -711,8 +722,8 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($this->isColumnModified(ConfigPeer::VALUE)) { $modifiedColumns[':p' . $index++] = '`VALUE`'; } - if ($this->isColumnModified(ConfigPeer::SECURE)) { - $modifiedColumns[':p' . $index++] = '`SECURE`'; + if ($this->isColumnModified(ConfigPeer::SECURED)) { + $modifiedColumns[':p' . $index++] = '`SECURED`'; } if ($this->isColumnModified(ConfigPeer::HIDDEN)) { $modifiedColumns[':p' . $index++] = '`HIDDEN`'; @@ -743,8 +754,8 @@ abstract class BaseConfig extends BaseObject implements Persistent case '`VALUE`': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`SECURE`': - $stmt->bindValue($identifier, $this->secure, PDO::PARAM_INT); + case '`SECURED`': + $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; case '`HIDDEN`': $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT); @@ -907,7 +918,7 @@ abstract class BaseConfig extends BaseObject implements Persistent return $this->getValue(); break; case 3: - return $this->getSecure(); + return $this->getSecured(); break; case 4: return $this->getHidden(); @@ -950,7 +961,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $keys[0] => $this->getId(), $keys[1] => $this->getName(), $keys[2] => $this->getValue(), - $keys[3] => $this->getSecure(), + $keys[3] => $this->getSecured(), $keys[4] => $this->getHidden(), $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), @@ -1003,7 +1014,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->setValue($value); break; case 3: - $this->setSecure($value); + $this->setSecured($value); break; case 4: $this->setHidden($value); @@ -1041,7 +1052,7 @@ abstract class BaseConfig extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setSecure($arr[$keys[3]]); + if (array_key_exists($keys[3], $arr)) $this->setSecured($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setHidden($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); @@ -1059,7 +1070,7 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($this->isColumnModified(ConfigPeer::ID)) $criteria->add(ConfigPeer::ID, $this->id); if ($this->isColumnModified(ConfigPeer::NAME)) $criteria->add(ConfigPeer::NAME, $this->name); if ($this->isColumnModified(ConfigPeer::VALUE)) $criteria->add(ConfigPeer::VALUE, $this->value); - if ($this->isColumnModified(ConfigPeer::SECURE)) $criteria->add(ConfigPeer::SECURE, $this->secure); + if ($this->isColumnModified(ConfigPeer::SECURED)) $criteria->add(ConfigPeer::SECURED, $this->secured); if ($this->isColumnModified(ConfigPeer::HIDDEN)) $criteria->add(ConfigPeer::HIDDEN, $this->hidden); if ($this->isColumnModified(ConfigPeer::CREATED_AT)) $criteria->add(ConfigPeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) $criteria->add(ConfigPeer::UPDATED_AT, $this->updated_at); @@ -1128,7 +1139,7 @@ abstract class BaseConfig extends BaseObject implements Persistent { $copyObj->setName($this->getName()); $copyObj->setValue($this->getValue()); - $copyObj->setSecure($this->getSecure()); + $copyObj->setSecured($this->getSecured()); $copyObj->setHidden($this->getHidden()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1427,7 +1438,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->id = null; $this->name = null; $this->value = null; - $this->secure = null; + $this->secured = null; $this->hidden = null; $this->created_at = null; $this->updated_at = null; @@ -1485,4 +1496,18 @@ abstract class BaseConfig extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Config The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ConfigPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseConfigDesc.php b/core/lib/Thelia/Model/om/BaseConfigDesc.php index 10b5dcb67..77d2ce177 100644 --- a/core/lib/Thelia/Model/om/BaseConfigDesc.php +++ b/core/lib/Thelia/Model/om/BaseConfigDesc.php @@ -610,8 +610,19 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ConfigDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ConfigDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ConfigDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseConfigDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ConfigDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ConfigDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseConfigDescQuery.php b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php index cf63e9603..763930070 100644 --- a/core/lib/Thelia/Model/om/BaseConfigDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseConfigDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseConfigDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ConfigDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ConfigDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ConfigDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ConfigDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ConfigDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ConfigDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ConfigDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseConfigPeer.php b/core/lib/Thelia/Model/om/BaseConfigPeer.php index fa800aedb..d2f78624a 100644 --- a/core/lib/Thelia/Model/om/BaseConfigPeer.php +++ b/core/lib/Thelia/Model/om/BaseConfigPeer.php @@ -54,8 +54,8 @@ abstract class BaseConfigPeer /** the column name for the VALUE field */ const VALUE = 'config.VALUE'; - /** the column name for the SECURE field */ - const SECURE = 'config.SECURE'; + /** the column name for the SECURED field */ + const SECURED = 'config.SECURED'; /** the column name for the HIDDEN field */ const HIDDEN = 'config.HIDDEN'; @@ -85,11 +85,11 @@ abstract class BaseConfigPeer * e.g. ConfigPeer::$fieldNames[ConfigPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Value', 'Secure', 'Hidden', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'value', 'secure', 'hidden', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ConfigPeer::ID, ConfigPeer::NAME, ConfigPeer::VALUE, ConfigPeer::SECURE, ConfigPeer::HIDDEN, ConfigPeer::CREATED_AT, ConfigPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'VALUE', 'SECURE', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'value', 'secure', 'hidden', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Value', 'Secured', 'Hidden', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'value', 'secured', 'hidden', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ConfigPeer::ID, ConfigPeer::NAME, ConfigPeer::VALUE, ConfigPeer::SECURED, ConfigPeer::HIDDEN, ConfigPeer::CREATED_AT, ConfigPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'VALUE', 'SECURED', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'value', 'secured', 'hidden', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -100,11 +100,11 @@ abstract class BaseConfigPeer * e.g. ConfigPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secure' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secure' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (ConfigPeer::ID => 0, ConfigPeer::NAME => 1, ConfigPeer::VALUE => 2, ConfigPeer::SECURE => 3, ConfigPeer::HIDDEN => 4, ConfigPeer::CREATED_AT => 5, ConfigPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURE' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secure' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secured' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + BasePeer::TYPE_COLNAME => array (ConfigPeer::ID => 0, ConfigPeer::NAME => 1, ConfigPeer::VALUE => 2, ConfigPeer::SECURED => 3, ConfigPeer::HIDDEN => 4, ConfigPeer::CREATED_AT => 5, ConfigPeer::UPDATED_AT => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURED' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -182,7 +182,7 @@ abstract class BaseConfigPeer $criteria->addSelectColumn(ConfigPeer::ID); $criteria->addSelectColumn(ConfigPeer::NAME); $criteria->addSelectColumn(ConfigPeer::VALUE); - $criteria->addSelectColumn(ConfigPeer::SECURE); + $criteria->addSelectColumn(ConfigPeer::SECURED); $criteria->addSelectColumn(ConfigPeer::HIDDEN); $criteria->addSelectColumn(ConfigPeer::CREATED_AT); $criteria->addSelectColumn(ConfigPeer::UPDATED_AT); @@ -190,7 +190,7 @@ abstract class BaseConfigPeer $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.SECURE'); + $criteria->addSelectColumn($alias . '.SECURED'); $criteria->addSelectColumn($alias . '.HIDDEN'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/om/BaseConfigQuery.php index a4090b85e..6a34c3ba5 100644 --- a/core/lib/Thelia/Model/om/BaseConfigQuery.php +++ b/core/lib/Thelia/Model/om/BaseConfigQuery.php @@ -25,7 +25,7 @@ use Thelia\Model\ConfigQuery; * @method ConfigQuery orderById($order = Criteria::ASC) Order by the id column * @method ConfigQuery orderByName($order = Criteria::ASC) Order by the name column * @method ConfigQuery orderByValue($order = Criteria::ASC) Order by the value column - * @method ConfigQuery orderBySecure($order = Criteria::ASC) Order by the secure column + * @method ConfigQuery orderBySecured($order = Criteria::ASC) Order by the secured column * @method ConfigQuery orderByHidden($order = Criteria::ASC) Order by the hidden column * @method ConfigQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ConfigQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -33,7 +33,7 @@ use Thelia\Model\ConfigQuery; * @method ConfigQuery groupById() Group by the id column * @method ConfigQuery groupByName() Group by the name column * @method ConfigQuery groupByValue() Group by the value column - * @method ConfigQuery groupBySecure() Group by the secure column + * @method ConfigQuery groupBySecured() Group by the secured column * @method ConfigQuery groupByHidden() Group by the hidden column * @method ConfigQuery groupByCreatedAt() Group by the created_at column * @method ConfigQuery groupByUpdatedAt() Group by the updated_at column @@ -52,7 +52,7 @@ use Thelia\Model\ConfigQuery; * @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 findOneBySecure(int $secure) Return the first Config filtered by the secure column + * @method Config findOneBySecured(int $secured) Return the first Config filtered by the secured column * @method Config findOneByHidden(int $hidden) Return the first Config filtered by the hidden column * @method Config findOneByCreatedAt(string $created_at) Return the first Config filtered by the created_at column * @method Config findOneByUpdatedAt(string $updated_at) Return the first Config filtered by the updated_at column @@ -60,7 +60,7 @@ use Thelia\Model\ConfigQuery; * @method array findById(int $id) Return Config objects filtered by the id column * @method array findByName(string $name) Return Config objects filtered by the name column * @method array findByValue(string $value) Return Config objects filtered by the value column - * @method array findBySecure(int $secure) Return Config objects filtered by the secure column + * @method array findBySecured(int $secured) Return Config objects filtered by the secured column * @method array findByHidden(int $hidden) Return Config objects filtered by the hidden column * @method array findByCreatedAt(string $created_at) Return Config objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return Config objects filtered by the updated_at column @@ -153,7 +153,7 @@ abstract class BaseConfigQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `NAME`, `VALUE`, `SECURE`, `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); @@ -328,16 +328,16 @@ abstract class BaseConfigQuery extends ModelCriteria } /** - * Filter the query on the secure column + * Filter the query on the secured column * * Example usage: * - * $query->filterBySecure(1234); // WHERE secure = 1234 - * $query->filterBySecure(array(12, 34)); // WHERE secure IN (12, 34) - * $query->filterBySecure(array('min' => 12)); // WHERE secure > 12 + * $query->filterBySecured(1234); // WHERE secured = 1234 + * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34) + * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 * * - * @param mixed $secure The value to use as filter. + * @param mixed $secured The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -345,16 +345,16 @@ abstract class BaseConfigQuery extends ModelCriteria * * @return ConfigQuery The current query, for fluid interface */ - public function filterBySecure($secure = null, $comparison = null) + public function filterBySecured($secured = null, $comparison = null) { - if (is_array($secure)) { + if (is_array($secured)) { $useMinMax = false; - if (isset($secure['min'])) { - $this->addUsingAlias(ConfigPeer::SECURE, $secure['min'], Criteria::GREATER_EQUAL); + if (isset($secured['min'])) { + $this->addUsingAlias(ConfigPeer::SECURED, $secured['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($secure['max'])) { - $this->addUsingAlias(ConfigPeer::SECURE, $secure['max'], Criteria::LESS_EQUAL); + if (isset($secured['max'])) { + $this->addUsingAlias(ConfigPeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -365,7 +365,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::SECURE, $secure, $comparison); + return $this->addUsingAlias(ConfigPeer::SECURED, $secured, $comparison); } /** @@ -585,4 +585,69 @@ abstract class BaseConfigQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ConfigQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ConfigPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ConfigQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ConfigPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ConfigQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ConfigPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ConfigQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ConfigPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ConfigQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ConfigPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ConfigQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ConfigPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php index f5dce9a13..efe3e5177 100644 --- a/core/lib/Thelia/Model/om/BaseContent.php +++ b/core/lib/Thelia/Model/om/BaseContent.php @@ -89,12 +89,6 @@ abstract class BaseContent extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - /** * @var PropelObjectCollection|ContentDesc[] Collection to store aggregation of ContentDesc objects. */ @@ -102,16 +96,10 @@ abstract class BaseContent extends BaseObject implements Persistent protected $collContentDescsPartial; /** - * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects. + * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. */ - protected $collContentFolders; - protected $collContentFoldersPartial; - - /** - * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; + protected $collContentAssocs; + protected $collContentAssocsPartial; /** * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects. @@ -119,12 +107,24 @@ abstract class BaseContent extends BaseObject implements Persistent protected $collImages; protected $collImagesPartial; + /** + * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. + */ + protected $collDocuments; + protected $collDocumentsPartial; + /** * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects. */ protected $collRewritings; protected $collRewritingsPartial; + /** + * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects. + */ + protected $collContentFolders; + protected $collContentFoldersPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -139,12 +139,6 @@ abstract class BaseContent extends BaseObject implements Persistent */ protected $alreadyInValidation = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -155,13 +149,7 @@ abstract class BaseContent extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $contentFoldersScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $documentsScheduledForDeletion = null; + protected $contentAssocsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -169,12 +157,24 @@ abstract class BaseContent extends BaseObject implements Persistent */ protected $imagesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $documentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ protected $rewritingsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $contentFoldersScheduledForDeletion = null; + /** * Get the [id] column value. * @@ -495,18 +495,18 @@ abstract class BaseContent extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collContentAssocs = null; - $this->collContentDescs = null; - $this->collContentFolders = null; - - $this->collDocuments = null; + $this->collContentAssocs = null; $this->collImages = null; + $this->collDocuments = null; + $this->collRewritings = null; + $this->collContentFolders = null; + } // if (deep) } @@ -579,8 +579,19 @@ abstract class BaseContent extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -631,24 +642,6 @@ abstract class BaseContent extends BaseObject implements Persistent $this->resetModified(); } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->contentDescsScheduledForDeletion !== null) { if (!$this->contentDescsScheduledForDeletion->isEmpty()) { ContentDescQuery::create() @@ -666,35 +659,18 @@ abstract class BaseContent extends BaseObject implements Persistent } } - if ($this->contentFoldersScheduledForDeletion !== null) { - if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() - ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentFoldersScheduledForDeletion = null; - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { + if ($this->contentAssocsScheduledForDeletion !== null) { + if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { + foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { // need to save related object because we set the relation to null - $document->save($con); + $contentAssoc->save($con); } - $this->documentsScheduledForDeletion = null; + $this->contentAssocsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } @@ -719,6 +695,24 @@ abstract class BaseContent extends BaseObject implements Persistent } } + if ($this->documentsScheduledForDeletion !== null) { + if (!$this->documentsScheduledForDeletion->isEmpty()) { + foreach ($this->documentsScheduledForDeletion as $document) { + // need to save related object because we set the relation to null + $document->save($con); + } + $this->documentsScheduledForDeletion = null; + } + } + + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { foreach ($this->rewritingsScheduledForDeletion as $rewriting) { @@ -737,6 +731,23 @@ abstract class BaseContent extends BaseObject implements Persistent } } + if ($this->contentFoldersScheduledForDeletion !== null) { + if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { + ContentFolderQuery::create() + ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->contentFoldersScheduledForDeletion = null; + } + } + + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -903,14 +914,6 @@ abstract class BaseContent extends BaseObject implements Persistent } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collContentDescs !== null) { foreach ($this->collContentDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -919,16 +922,8 @@ abstract class BaseContent extends BaseObject implements Persistent } } - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -943,6 +938,14 @@ abstract class BaseContent extends BaseObject implements Persistent } } + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -951,6 +954,14 @@ abstract class BaseContent extends BaseObject implements Persistent } } + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + $this->alreadyInValidation = false; } @@ -1037,24 +1048,24 @@ abstract class BaseContent extends BaseObject implements Persistent $keys[4] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collContentDescs) { $result['ContentDescs'] = $this->collContentDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentFolders) { - $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collContentAssocs) { + $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collImages) { $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collDocuments) { + $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collContentFolders) { + $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1224,27 +1235,15 @@ abstract class BaseContent extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - foreach ($this->getContentDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentDesc($relObj->copy($deepCopy)); } } - foreach ($this->getContentFolders() as $relObj) { + foreach ($this->getContentAssocs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentFolder($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); + $copyObj->addContentAssoc($relObj->copy($deepCopy)); } } @@ -1254,12 +1253,24 @@ abstract class BaseContent extends BaseObject implements Persistent } } + foreach ($this->getDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); } } + foreach ($this->getContentFolders() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentFolder($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1321,24 +1332,231 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } if ('ContentDesc' == $relationName) { $this->initContentDescs(); } - if ('ContentFolder' == $relationName) { - $this->initContentFolders(); - } - if ('Document' == $relationName) { - $this->initDocuments(); + if ('ContentAssoc' == $relationName) { + $this->initContentAssocs(); } if ('Image' == $relationName) { $this->initImages(); } + if ('Document' == $relationName) { + $this->initDocuments(); + } if ('Rewriting' == $relationName) { $this->initRewritings(); } + if ('ContentFolder' == $relationName) { + $this->initContentFolders(); + } + } + + /** + * Clears out the collContentDescs collection + * + * 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 + * @see addContentDescs() + */ + public function clearContentDescs() + { + $this->collContentDescs = null; // important to set this to null since that means it is uninitialized + $this->collContentDescsPartial = null; + } + + /** + * reset is the collContentDescs collection loaded partially + * + * @return void + */ + public function resetPartialContentDescs($v = true) + { + $this->collContentDescsPartial = $v; + } + + /** + * Initializes the collContentDescs collection. + * + * By default this just sets the collContentDescs collection to an empty array (like clearcollContentDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentDescs($overrideExisting = true) + { + if (null !== $this->collContentDescs && !$overrideExisting) { + return; + } + $this->collContentDescs = new PropelObjectCollection(); + $this->collContentDescs->setModel('ContentDesc'); + } + + /** + * Gets an array of ContentDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Content is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ContentDesc[] List of ContentDesc objects + * @throws PropelException + */ + public function getContentDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collContentDescsPartial && !$this->isNew(); + if (null === $this->collContentDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDescs) { + // return empty collection + $this->initContentDescs(); + } else { + $collContentDescs = ContentDescQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collContentDescsPartial && count($collContentDescs)) { + $this->initContentDescs(false); + + foreach($collContentDescs as $obj) { + if (false == $this->collContentDescs->contains($obj)) { + $this->collContentDescs->append($obj); + } + } + + $this->collContentDescsPartial = true; + } + + return $collContentDescs; + } + + if($partial && $this->collContentDescs) { + foreach($this->collContentDescs as $obj) { + if($obj->isNew()) { + $collContentDescs[] = $obj; + } + } + } + + $this->collContentDescs = $collContentDescs; + $this->collContentDescsPartial = false; + } + } + + return $this->collContentDescs; + } + + /** + * Sets a collection of ContentDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $contentDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setContentDescs(PropelCollection $contentDescs, PropelPDO $con = null) + { + $this->contentDescsScheduledForDeletion = $this->getContentDescs(new Criteria(), $con)->diff($contentDescs); + + foreach ($this->contentDescsScheduledForDeletion as $contentDescRemoved) { + $contentDescRemoved->setContent(null); + } + + $this->collContentDescs = null; + foreach ($contentDescs as $contentDesc) { + $this->addContentDesc($contentDesc); + } + + $this->collContentDescs = $contentDescs; + $this->collContentDescsPartial = false; + } + + /** + * Returns the number of related ContentDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ContentDesc objects. + * @throws PropelException + */ + public function countContentDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collContentDescsPartial && !$this->isNew(); + if (null === $this->collContentDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getContentDescs()); + } + $query = ContentDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + } else { + return count($this->collContentDescs); + } + } + + /** + * Method called to associate a ContentDesc object to this object + * through the ContentDesc foreign key attribute. + * + * @param ContentDesc $l ContentDesc + * @return Content The current object (for fluent API support) + */ + public function addContentDesc(ContentDesc $l) + { + if ($this->collContentDescs === null) { + $this->initContentDescs(); + $this->collContentDescsPartial = true; + } + if (!$this->collContentDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddContentDesc($l); + } + + return $this; + } + + /** + * @param ContentDesc $contentDesc The contentDesc object to add. + */ + protected function doAddContentDesc($contentDesc) + { + $this->collContentDescs[]= $contentDesc; + $contentDesc->setContent($this); + } + + /** + * @param ContentDesc $contentDesc The contentDesc object to remove. + */ + public function removeContentDesc($contentDesc) + { + if ($this->getContentDescs()->contains($contentDesc)) { + $this->collContentDescs->remove($this->collContentDescs->search($contentDesc)); + if (null === $this->contentDescsScheduledForDeletion) { + $this->contentDescsScheduledForDeletion = clone $this->collContentDescs; + $this->contentDescsScheduledForDeletion->clear(); + } + $this->contentDescsScheduledForDeletion[]= $contentDesc; + $contentDesc->setContent(null); + } } /** @@ -1598,727 +1816,6 @@ abstract class BaseContent extends BaseObject implements Persistent return $this->getContentAssocs($query, $con); } - /** - * Clears out the collContentDescs collection - * - * 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 - * @see addContentDescs() - */ - public function clearContentDescs() - { - $this->collContentDescs = null; // important to set this to null since that means it is uninitialized - $this->collContentDescsPartial = null; - } - - /** - * reset is the collContentDescs collection loaded partially - * - * @return void - */ - public function resetPartialContentDescs($v = true) - { - $this->collContentDescsPartial = $v; - } - - /** - * Initializes the collContentDescs collection. - * - * By default this just sets the collContentDescs collection to an empty array (like clearcollContentDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentDescs($overrideExisting = true) - { - if (null !== $this->collContentDescs && !$overrideExisting) { - return; - } - $this->collContentDescs = new PropelObjectCollection(); - $this->collContentDescs->setModel('ContentDesc'); - } - - /** - * Gets an array of ContentDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentDesc[] List of ContentDesc objects - * @throws PropelException - */ - public function getContentDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentDescsPartial && !$this->isNew(); - if (null === $this->collContentDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentDescs) { - // return empty collection - $this->initContentDescs(); - } else { - $collContentDescs = ContentDescQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentDescsPartial && count($collContentDescs)) { - $this->initContentDescs(false); - - foreach($collContentDescs as $obj) { - if (false == $this->collContentDescs->contains($obj)) { - $this->collContentDescs->append($obj); - } - } - - $this->collContentDescsPartial = true; - } - - return $collContentDescs; - } - - if($partial && $this->collContentDescs) { - foreach($this->collContentDescs as $obj) { - if($obj->isNew()) { - $collContentDescs[] = $obj; - } - } - } - - $this->collContentDescs = $collContentDescs; - $this->collContentDescsPartial = false; - } - } - - return $this->collContentDescs; - } - - /** - * Sets a collection of ContentDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setContentDescs(PropelCollection $contentDescs, PropelPDO $con = null) - { - $this->contentDescsScheduledForDeletion = $this->getContentDescs(new Criteria(), $con)->diff($contentDescs); - - foreach ($this->contentDescsScheduledForDeletion as $contentDescRemoved) { - $contentDescRemoved->setContent(null); - } - - $this->collContentDescs = null; - foreach ($contentDescs as $contentDesc) { - $this->addContentDesc($contentDesc); - } - - $this->collContentDescs = $contentDescs; - $this->collContentDescsPartial = false; - } - - /** - * Returns the number of related ContentDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentDesc objects. - * @throws PropelException - */ - public function countContentDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentDescsPartial && !$this->isNew(); - if (null === $this->collContentDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getContentDescs()); - } - $query = ContentDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - } else { - return count($this->collContentDescs); - } - } - - /** - * Method called to associate a ContentDesc object to this object - * through the ContentDesc foreign key attribute. - * - * @param ContentDesc $l ContentDesc - * @return Content The current object (for fluent API support) - */ - public function addContentDesc(ContentDesc $l) - { - if ($this->collContentDescs === null) { - $this->initContentDescs(); - $this->collContentDescsPartial = true; - } - if (!$this->collContentDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddContentDesc($l); - } - - return $this; - } - - /** - * @param ContentDesc $contentDesc The contentDesc object to add. - */ - protected function doAddContentDesc($contentDesc) - { - $this->collContentDescs[]= $contentDesc; - $contentDesc->setContent($this); - } - - /** - * @param ContentDesc $contentDesc The contentDesc object to remove. - */ - public function removeContentDesc($contentDesc) - { - if ($this->getContentDescs()->contains($contentDesc)) { - $this->collContentDescs->remove($this->collContentDescs->search($contentDesc)); - if (null === $this->contentDescsScheduledForDeletion) { - $this->contentDescsScheduledForDeletion = clone $this->collContentDescs; - $this->contentDescsScheduledForDeletion->clear(); - } - $this->contentDescsScheduledForDeletion[]= $contentDesc; - $contentDesc->setContent(null); - } - } - - /** - * Clears out the collContentFolders collection - * - * 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 - * @see addContentFolders() - */ - public function clearContentFolders() - { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - } - - /** - * reset is the collContentFolders collection loaded partially - * - * @return void - */ - public function resetPartialContentFolders($v = true) - { - $this->collContentFoldersPartial = $v; - } - - /** - * Initializes the collContentFolders collection. - * - * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentFolders($overrideExisting = true) - { - if (null !== $this->collContentFolders && !$overrideExisting) { - return; - } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); - } - - /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - * @throws PropelException - */ - public function getContentFolders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - // return empty collection - $this->initContentFolders(); - } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); - - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); - } - } - - $this->collContentFoldersPartial = true; - } - - return $collContentFolders; - } - - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { - $collContentFolders[] = $obj; - } - } - } - - $this->collContentFolders = $collContentFolders; - $this->collContentFoldersPartial = false; - } - } - - return $this->collContentFolders; - } - - /** - * Sets a collection of ContentFolder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentFolders A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) - { - $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - - foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { - $contentFolderRemoved->setContent(null); - } - - $this->collContentFolders = null; - foreach ($contentFolders as $contentFolder) { - $this->addContentFolder($contentFolder); - } - - $this->collContentFolders = $contentFolders; - $this->collContentFoldersPartial = false; - } - - /** - * Returns the number of related ContentFolder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentFolder objects. - * @throws PropelException - */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. - * - * @param ContentFolder $l ContentFolder - * @return Content The current object (for fluent API support) - */ - public function addContentFolder(ContentFolder $l) - { - if ($this->collContentFolders === null) { - $this->initContentFolders(); - $this->collContentFoldersPartial = true; - } - if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddContentFolder($l); - } - - return $this; - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to add. - */ - protected function doAddContentFolder($contentFolder) - { - $this->collContentFolders[]= $contentFolder; - $contentFolder->setContent($this); - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - */ - public function removeContentFolder($contentFolder) - { - if ($this->getContentFolders()->contains($contentFolder)) { - $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); - if (null === $this->contentFoldersScheduledForDeletion) { - $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; - $this->contentFoldersScheduledForDeletion->clear(); - } - $this->contentFoldersScheduledForDeletion[]= $contentFolder; - $contentFolder->setContent(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentFolders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - */ - public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getContentFolders($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * 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 - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); - - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { - $documentRemoved->setContent(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Content The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setContent($this); - } - - /** - * @param Document $document The document object to remove. - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setContent(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - /** * Clears out the collImages collection * @@ -2601,6 +2098,288 @@ abstract class BaseContent extends BaseObject implements Persistent return $this->getImages($query, $con); } + /** + * Clears out the collDocuments collection + * + * 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 + * @see addDocuments() + */ + public function clearDocuments() + { + $this->collDocuments = null; // important to set this to null since that means it is uninitialized + $this->collDocumentsPartial = null; + } + + /** + * reset is the collDocuments collection loaded partially + * + * @return void + */ + public function resetPartialDocuments($v = true) + { + $this->collDocumentsPartial = $v; + } + + /** + * Initializes the collDocuments collection. + * + * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initDocuments($overrideExisting = true) + { + if (null !== $this->collDocuments && !$overrideExisting) { + return; + } + $this->collDocuments = new PropelObjectCollection(); + $this->collDocuments->setModel('Document'); + } + + /** + * Gets an array of Document objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Content is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Document[] List of Document objects + * @throws PropelException + */ + public function getDocuments($criteria = null, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + if (null === $this->collDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collDocuments) { + // return empty collection + $this->initDocuments(); + } else { + $collDocuments = DocumentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collDocumentsPartial && count($collDocuments)) { + $this->initDocuments(false); + + foreach($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } + } + + $this->collDocumentsPartial = true; + } + + return $collDocuments; + } + + if($partial && $this->collDocuments) { + foreach($this->collDocuments as $obj) { + if($obj->isNew()) { + $collDocuments[] = $obj; + } + } + } + + $this->collDocuments = $collDocuments; + $this->collDocumentsPartial = false; + } + } + + return $this->collDocuments; + } + + /** + * Sets a collection of Document objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $documents A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + { + $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + + foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $documentRemoved->setContent(null); + } + + $this->collDocuments = null; + foreach ($documents as $document) { + $this->addDocument($document); + } + + $this->collDocuments = $documents; + $this->collDocumentsPartial = false; + } + + /** + * Returns the number of related Document objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Document objects. + * @throws PropelException + */ + public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Document object to this object + * through the Document foreign key attribute. + * + * @param Document $l Document + * @return Content The current object (for fluent API support) + */ + public function addDocument(Document $l) + { + if ($this->collDocuments === null) { + $this->initDocuments(); + $this->collDocumentsPartial = true; + } + if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddDocument($l); + } + + return $this; + } + + /** + * @param Document $document The document object to add. + */ + protected function doAddDocument($document) + { + $this->collDocuments[]= $document; + $document->setContent($this); + } + + /** + * @param Document $document The document object to remove. + */ + public function removeDocument($document) + { + if ($this->getDocuments()->contains($document)) { + $this->collDocuments->remove($this->collDocuments->search($document)); + if (null === $this->documentsScheduledForDeletion) { + $this->documentsScheduledForDeletion = clone $this->collDocuments; + $this->documentsScheduledForDeletion->clear(); + } + $this->documentsScheduledForDeletion[]= $document; + $document->setContent(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Product', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $join_behavior); + + return $this->getDocuments($query, $con); + } + /** * Clears out the collRewritings collection * @@ -2883,6 +2662,238 @@ abstract class BaseContent extends BaseObject implements Persistent return $this->getRewritings($query, $con); } + /** + * Clears out the collContentFolders collection + * + * 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 + * @see addContentFolders() + */ + public function clearContentFolders() + { + $this->collContentFolders = null; // important to set this to null since that means it is uninitialized + $this->collContentFoldersPartial = null; + } + + /** + * reset is the collContentFolders collection loaded partially + * + * @return void + */ + public function resetPartialContentFolders($v = true) + { + $this->collContentFoldersPartial = $v; + } + + /** + * Initializes the collContentFolders collection. + * + * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentFolders($overrideExisting = true) + { + if (null !== $this->collContentFolders && !$overrideExisting) { + return; + } + $this->collContentFolders = new PropelObjectCollection(); + $this->collContentFolders->setModel('ContentFolder'); + } + + /** + * Gets an array of ContentFolder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Content is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects + * @throws PropelException + */ + public function getContentFolders($criteria = null, PropelPDO $con = null) + { + $partial = $this->collContentFoldersPartial && !$this->isNew(); + if (null === $this->collContentFolders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentFolders) { + // return empty collection + $this->initContentFolders(); + } else { + $collContentFolders = ContentFolderQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { + $this->initContentFolders(false); + + foreach($collContentFolders as $obj) { + if (false == $this->collContentFolders->contains($obj)) { + $this->collContentFolders->append($obj); + } + } + + $this->collContentFoldersPartial = true; + } + + return $collContentFolders; + } + + if($partial && $this->collContentFolders) { + foreach($this->collContentFolders as $obj) { + if($obj->isNew()) { + $collContentFolders[] = $obj; + } + } + } + + $this->collContentFolders = $collContentFolders; + $this->collContentFoldersPartial = false; + } + } + + return $this->collContentFolders; + } + + /** + * Sets a collection of ContentFolder objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $contentFolders A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) + { + $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); + + foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { + $contentFolderRemoved->setContent(null); + } + + $this->collContentFolders = null; + foreach ($contentFolders as $contentFolder) { + $this->addContentFolder($contentFolder); + } + + $this->collContentFolders = $contentFolders; + $this->collContentFoldersPartial = false; + } + + /** + * Returns the number of related ContentFolder objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ContentFolder objects. + * @throws PropelException + */ + public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collContentFoldersPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a ContentFolder object to this object + * through the ContentFolder foreign key attribute. + * + * @param ContentFolder $l ContentFolder + * @return Content The current object (for fluent API support) + */ + public function addContentFolder(ContentFolder $l) + { + if ($this->collContentFolders === null) { + $this->initContentFolders(); + $this->collContentFoldersPartial = true; + } + if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddContentFolder($l); + } + + return $this; + } + + /** + * @param ContentFolder $contentFolder The contentFolder object to add. + */ + protected function doAddContentFolder($contentFolder) + { + $this->collContentFolders[]= $contentFolder; + $contentFolder->setContent($this); + } + + /** + * @param ContentFolder $contentFolder The contentFolder object to remove. + */ + public function removeContentFolder($contentFolder) + { + if ($this->getContentFolders()->contains($contentFolder)) { + $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); + if (null === $this->contentFoldersScheduledForDeletion) { + $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; + $this->contentFoldersScheduledForDeletion->clear(); + } + $this->contentFoldersScheduledForDeletion[]= $contentFolder; + $contentFolder->setContent(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Content is new, it will return + * an empty collection; or if this Content has previously + * been saved, it will retrieve related ContentFolders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Content. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects + */ + public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ContentFolderQuery::create(null, $criteria); + $query->joinWith('Folder', $join_behavior); + + return $this->getContentFolders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -2913,23 +2924,13 @@ abstract class BaseContent extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collContentDescs) { foreach ($this->collContentDescs as $o) { $o->clearAllReferences($deep); } } - if ($this->collContentFolders) { - foreach ($this->collContentFolders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { + if ($this->collContentAssocs) { + foreach ($this->collContentAssocs as $o) { $o->clearAllReferences($deep); } } @@ -2938,37 +2939,47 @@ abstract class BaseContent extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->collDocuments) { + foreach ($this->collDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); } } + if ($this->collContentFolders) { + foreach ($this->collContentFolders as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; if ($this->collContentDescs instanceof PropelCollection) { $this->collContentDescs->clearIterator(); } $this->collContentDescs = null; - if ($this->collContentFolders instanceof PropelCollection) { - $this->collContentFolders->clearIterator(); + if ($this->collContentAssocs instanceof PropelCollection) { + $this->collContentAssocs->clearIterator(); } - $this->collContentFolders = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; + $this->collContentAssocs = null; if ($this->collImages instanceof PropelCollection) { $this->collImages->clearIterator(); } $this->collImages = null; + if ($this->collDocuments instanceof PropelCollection) { + $this->collDocuments->clearIterator(); + } + $this->collDocuments = null; if ($this->collRewritings instanceof PropelCollection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; + if ($this->collContentFolders instanceof PropelCollection) { + $this->collContentFolders->clearIterator(); + } + $this->collContentFolders = null; } /** @@ -2991,4 +3002,18 @@ abstract class BaseContent extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Content The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseContentAssoc.php b/core/lib/Thelia/Model/om/BaseContentAssoc.php index c98102990..f13919b72 100644 --- a/core/lib/Thelia/Model/om/BaseContentAssoc.php +++ b/core/lib/Thelia/Model/om/BaseContentAssoc.php @@ -602,8 +602,19 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentAssocPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1428,4 +1439,18 @@ abstract class BaseContentAssoc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ContentAssoc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentAssocPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php index d36c9216c..cad72948c 100644 --- a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php @@ -779,4 +779,69 @@ abstract class BaseContentAssocQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentAssocPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentAssocPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentAssocPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentAssocPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ContentAssocQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentAssocPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseContentDesc.php b/core/lib/Thelia/Model/om/BaseContentDesc.php index decccecc6..fd03fd1e2 100644 --- a/core/lib/Thelia/Model/om/BaseContentDesc.php +++ b/core/lib/Thelia/Model/om/BaseContentDesc.php @@ -648,8 +648,19 @@ abstract class BaseContentDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1372,4 +1383,18 @@ abstract class BaseContentDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ContentDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseContentDescQuery.php b/core/lib/Thelia/Model/om/BaseContentDescQuery.php index 4e78ae8e9..a3f2a803d 100644 --- a/core/lib/Thelia/Model/om/BaseContentDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentDescQuery.php @@ -643,4 +643,69 @@ abstract class BaseContentDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ContentDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseContentFolder.php b/core/lib/Thelia/Model/om/BaseContentFolder.php index 83fe4363c..37997e02c 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolder.php +++ b/core/lib/Thelia/Model/om/BaseContentFolder.php @@ -5,10 +5,12 @@ namespace Thelia\Model\om; use \BaseObject; use \BasePeer; use \Criteria; +use \DateTime; use \Exception; use \PDO; use \Persistent; use \Propel; +use \PropelDateTime; use \PropelException; use \PropelPDO; use Thelia\Model\Content; @@ -59,6 +61,18 @@ abstract class BaseContentFolder extends BaseObject implements Persistent */ protected $folder_id; + /** + * The value for the created_at field. + * @var string + */ + protected $created_at; + + /** + * The value for the updated_at field. + * @var string + */ + protected $updated_at; + /** * @var Content */ @@ -103,6 +117,80 @@ abstract class BaseContentFolder extends BaseObject implements Persistent return $this->folder_id; } + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + if ($this->created_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + if ($this->updated_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + /** * Set the value of [content_id] column. * @@ -153,6 +241,52 @@ abstract class BaseContentFolder extends BaseObject implements Persistent return $this; } // setFolderId() + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return ContentFolder The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = ContentFolderPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return ContentFolder The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = ContentFolderPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + /** * Indicates whether the columns in this object are only set to default values. * @@ -187,6 +321,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $this->content_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->folder_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->resetModified(); $this->setNew(false); @@ -195,7 +331,7 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 2; // 2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 4; // 4 = ContentFolderPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating ContentFolder object", $e); @@ -337,8 +473,19 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentFolderPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -436,6 +583,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) { $modifiedColumns[':p' . $index++] = '`FOLDER_ID`'; } + if ($this->isColumnModified(ContentFolderPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + } + if ($this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + } $sql = sprintf( 'INSERT INTO `content_folder` (%s) VALUES (%s)', @@ -453,6 +606,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent case '`FOLDER_ID`': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; + case '`CREATED_AT`': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '`UPDATED_AT`': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -604,6 +763,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent case 1: return $this->getFolderId(); break; + case 2: + return $this->getCreatedAt(); + break; + case 3: + return $this->getUpdatedAt(); + break; default: return null; break; @@ -635,6 +800,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent $result = array( $keys[0] => $this->getContentId(), $keys[1] => $this->getFolderId(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { if (null !== $this->aContent) { @@ -683,6 +850,12 @@ abstract class BaseContentFolder extends BaseObject implements Persistent case 1: $this->setFolderId($value); break; + case 2: + $this->setCreatedAt($value); + break; + case 3: + $this->setUpdatedAt($value); + break; } // switch() } @@ -709,6 +882,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); } /** @@ -722,6 +897,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) $criteria->add(ContentFolderPeer::CONTENT_ID, $this->content_id); if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) $criteria->add(ContentFolderPeer::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(ContentFolderPeer::CREATED_AT)) $criteria->add(ContentFolderPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentFolderPeer::UPDATED_AT)) $criteria->add(ContentFolderPeer::UPDATED_AT, $this->updated_at); return $criteria; } @@ -794,6 +971,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent { $copyObj->setContentId($this->getContentId()); $copyObj->setFolderId($this->getFolderId()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -960,6 +1139,8 @@ abstract class BaseContentFolder extends BaseObject implements Persistent { $this->content_id = null; $this->folder_id = null; + $this->created_at = null; + $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); @@ -1006,4 +1187,18 @@ abstract class BaseContentFolder extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ContentFolder The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentFolderPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php index d0168ded1..30a858ff2 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php @@ -38,13 +38,13 @@ abstract class BaseContentFolderPeer const TM_CLASS = 'ContentFolderTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 2; + const NUM_COLUMNS = 4; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 2; + const NUM_HYDRATE_COLUMNS = 4; /** the column name for the CONTENT_ID field */ const CONTENT_ID = 'content_folder.CONTENT_ID'; @@ -52,6 +52,12 @@ abstract class BaseContentFolderPeer /** 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 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'; @@ -71,12 +77,12 @@ abstract class BaseContentFolderPeer * e.g. ContentFolderPeer::$fieldNames[ContentFolderPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('ContentId', 'FolderId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('contentId', 'folderId', ), - BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID, ContentFolderPeer::FOLDER_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID', 'FOLDER_ID', ), - BasePeer::TYPE_FIELDNAME => array ('content_id', 'folder_id', ), - BasePeer::TYPE_NUM => array (0, 1, ) + BasePeer::TYPE_PHPNAME => array ('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('contentId', 'folderId', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID, ContentFolderPeer::FOLDER_ID, ContentFolderPeer::CREATED_AT, ContentFolderPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('content_id', 'folder_id', 'created_at', 'updated_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) ); /** @@ -86,12 +92,12 @@ abstract class BaseContentFolderPeer * e.g. ContentFolderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('ContentId' => 0, 'FolderId' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('contentId' => 0, 'folderId' => 1, ), - BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID => 0, ContentFolderPeer::FOLDER_ID => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID' => 0, 'FOLDER_ID' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('content_id' => 0, 'folder_id' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) + BasePeer::TYPE_PHPNAME => array ('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID => 0, ContentFolderPeer::FOLDER_ID => 1, ContentFolderPeer::CREATED_AT => 2, ContentFolderPeer::UPDATED_AT => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) ); /** @@ -167,9 +173,13 @@ abstract class BaseContentFolderPeer if (null === $alias) { $criteria->addSelectColumn(ContentFolderPeer::CONTENT_ID); $criteria->addSelectColumn(ContentFolderPeer::FOLDER_ID); + $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'); } } diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php index ad5dffc3a..bea1b9b9c 100644 --- a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php @@ -25,9 +25,13 @@ use Thelia\Model\Folder; * * @method ContentFolderQuery orderByContentId($order = Criteria::ASC) Order by the content_id column * @method ContentFolderQuery orderByFolderId($order = Criteria::ASC) Order by the folder_id column + * @method ContentFolderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ContentFolderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ContentFolderQuery groupByContentId() Group by the content_id column * @method ContentFolderQuery groupByFolderId() Group by the folder_id column + * @method ContentFolderQuery groupByCreatedAt() Group by the created_at column + * @method ContentFolderQuery groupByUpdatedAt() Group by the updated_at column * * @method ContentFolderQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ContentFolderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -46,9 +50,13 @@ use Thelia\Model\Folder; * * @method ContentFolder findOneByContentId(int $content_id) Return the first ContentFolder filtered by the content_id column * @method ContentFolder findOneByFolderId(int $folder_id) Return the first ContentFolder filtered by the folder_id column + * @method ContentFolder findOneByCreatedAt(string $created_at) Return the first ContentFolder filtered by the created_at column + * @method ContentFolder findOneByUpdatedAt(string $updated_at) Return the first ContentFolder filtered by the updated_at column * * @method array findByContentId(int $content_id) Return ContentFolder objects filtered by the content_id column * @method array findByFolderId(int $folder_id) Return ContentFolder objects filtered by the folder_id column + * @method array findByCreatedAt(string $created_at) Return ContentFolder objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ContentFolder objects filtered by the updated_at column * * @package propel.generator.Thelia.Model.om */ @@ -139,7 +147,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `CONTENT_ID`, `FOLDER_ID` 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); @@ -298,6 +306,92 @@ abstract class BaseContentFolderQuery extends ModelCriteria return $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId, $comparison); } + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt, $comparison); + } + /** * Filter the query by a related Content object * @@ -468,4 +562,69 @@ abstract class BaseContentFolderQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentFolderPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentFolderPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentFolderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentFolderPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ContentFolderQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentFolderPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php index 85f317aa4..e2e823bc6 100644 --- a/core/lib/Thelia/Model/om/BaseContentPeer.php +++ b/core/lib/Thelia/Model/om/BaseContentPeer.php @@ -388,24 +388,24 @@ abstract class BaseContentPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); // Invalidate objects in ContentDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentDescPeer::clearInstancePool(); - // Invalidate objects in ContentFolderPeer instance pool, + // Invalidate objects in ContentAssocPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentFolderPeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); + ContentAssocPeer::clearInstancePool(); // Invalidate objects in ImagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ImagePeer::clearInstancePool(); + // Invalidate objects in DocumentPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + DocumentPeer::clearInstancePool(); // Invalidate objects in RewritingPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RewritingPeer::clearInstancePool(); + // Invalidate objects in ContentFolderPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentFolderPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php index 6c0e852ed..5108d053d 100644 --- a/core/lib/Thelia/Model/om/BaseContentQuery.php +++ b/core/lib/Thelia/Model/om/BaseContentQuery.php @@ -43,30 +43,30 @@ use Thelia\Model\Rewriting; * @method ContentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ContentQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ContentQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ContentQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ContentQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * * @method ContentQuery leftJoinContentDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentDesc relation * @method ContentQuery rightJoinContentDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentDesc relation * @method ContentQuery innerJoinContentDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentDesc relation * - * @method ContentQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation - * @method ContentQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation - * @method ContentQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation - * - * @method ContentQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ContentQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ContentQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * @method ContentQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation + * @method ContentQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation + * @method ContentQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation * * @method ContentQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation * @method ContentQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation * @method ContentQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation * + * @method ContentQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation + * @method ContentQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation + * @method ContentQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * * @method ContentQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ContentQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ContentQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation * + * @method ContentQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation + * @method ContentQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation + * @method ContentQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation + * * @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 * @@ -454,80 +454,6 @@ abstract class BaseContentQuery extends ModelCriteria return $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related ContentAssoc object - * - * @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. - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof ContentAssoc) { - return $this - ->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - /** * Filter the query by a related ContentDesc object * @@ -603,41 +529,41 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related ContentFolder object + * Filter the query by a related ContentAssoc object * - * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter + * @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. */ - public function filterByContentFolder($contentFolder, $comparison = null) + public function filterByContentAssoc($contentAssoc, $comparison = null) { - if ($contentFolder instanceof ContentFolder) { + if ($contentAssoc instanceof ContentAssoc) { return $this - ->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { + ->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison); + } elseif ($contentAssoc instanceof PropelObjectCollection) { return $this - ->useContentFolderQuery() - ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) + ->useContentAssocQuery() + ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); + throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the ContentFolder relation + * Adds a JOIN clause to the query using the ContentAssoc relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ContentQuery The current query, for fluid interface */ - public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentFolder'); + $relationMap = $tableMap->getRelation('ContentAssoc'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -652,14 +578,14 @@ abstract class BaseContentQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'ContentFolder'); + $this->addJoinObject($join, 'ContentAssoc'); } return $this; } /** - * Use the ContentFolder relation ContentFolder object + * Use the ContentAssoc relation ContentAssoc object * * @see useQuery() * @@ -667,87 +593,13 @@ abstract class BaseContentQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query */ - public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this - ->joinContentFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); - } - - /** - * Filter the query by a related Document object - * - * @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. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + ->joinContentAssoc($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); } /** @@ -824,6 +676,80 @@ abstract class BaseContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); } + /** + * Filter the query by a related Document object + * + * @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. + */ + public function filterByDocument($document, $comparison = null) + { + if ($document instanceof Document) { + return $this + ->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison); + } elseif ($document instanceof PropelObjectCollection) { + return $this + ->useDocumentQuery() + ->filterByPrimaryKeys($document->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Document relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ContentQuery The current query, for fluid interface + */ + public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Document'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Document'); + } + + return $this; + } + + /** + * Use the Document relation Document object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query + */ + public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + } + /** * Filter the query by a related Rewriting object * @@ -898,6 +824,80 @@ abstract class BaseContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); } + /** + * Filter the query by a related ContentFolder object + * + * @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. + */ + public function filterByContentFolder($contentFolder, $comparison = null) + { + if ($contentFolder instanceof ContentFolder) { + return $this + ->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison); + } elseif ($contentFolder instanceof PropelObjectCollection) { + return $this + ->useContentFolderQuery() + ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentFolder relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ContentQuery The current query, for fluid interface + */ + public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentFolder'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentFolder'); + } + + return $this; + } + + /** + * Use the ContentFolder relation ContentFolder object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query + */ + public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContentFolder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); + } + /** * Exclude object from result * @@ -914,4 +914,69 @@ abstract class BaseContentQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCountry.php b/core/lib/Thelia/Model/om/BaseCountry.php index b19a6f777..81592ea5e 100644 --- a/core/lib/Thelia/Model/om/BaseCountry.php +++ b/core/lib/Thelia/Model/om/BaseCountry.php @@ -606,8 +606,19 @@ abstract class BaseCountry extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CountryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CountryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CountryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1855,4 +1866,18 @@ abstract class BaseCountry extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Country The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CountryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCountryDesc.php b/core/lib/Thelia/Model/om/BaseCountryDesc.php index 105007c9b..2d4bce448 100644 --- a/core/lib/Thelia/Model/om/BaseCountryDesc.php +++ b/core/lib/Thelia/Model/om/BaseCountryDesc.php @@ -610,8 +610,19 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CountryDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CountryDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CountryDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseCountryDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CountryDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CountryDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCountryDescQuery.php b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php index 3e71b9628..b91c7f343 100644 --- a/core/lib/Thelia/Model/om/BaseCountryDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseCountryDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseCountryDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CountryDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CountryDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CountryDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CountryDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CountryDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CountryDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CountryDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/om/BaseCountryQuery.php index 27500b9fd..dc04359d0 100644 --- a/core/lib/Thelia/Model/om/BaseCountryQuery.php +++ b/core/lib/Thelia/Model/om/BaseCountryQuery.php @@ -735,4 +735,69 @@ abstract class BaseCountryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CountryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CountryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CountryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CountryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CountryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CountryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CountryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CountryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CountryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CountryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CountryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CountryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/om/BaseCoupon.php index 6f2d237c2..639cfc5e0 100644 --- a/core/lib/Thelia/Model/om/BaseCoupon.php +++ b/core/lib/Thelia/Model/om/BaseCoupon.php @@ -747,8 +747,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CouponPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CouponPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CouponPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1675,4 +1686,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Coupon The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CouponPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCouponOrder.php b/core/lib/Thelia/Model/om/BaseCouponOrder.php index 296fd0e6a..60a6e581d 100644 --- a/core/lib/Thelia/Model/om/BaseCouponOrder.php +++ b/core/lib/Thelia/Model/om/BaseCouponOrder.php @@ -534,8 +534,19 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CouponOrderPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1207,4 +1218,18 @@ abstract class BaseCouponOrder extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CouponOrder The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CouponOrderPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php index c0e40c227..8f29b1a0e 100644 --- a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php @@ -556,4 +556,69 @@ abstract class BaseCouponOrderQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponOrderPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponOrderPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CouponOrderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CouponOrderPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CouponOrderQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CouponOrderPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/om/BaseCouponQuery.php index 267f44074..d47b8a071 100644 --- a/core/lib/Thelia/Model/om/BaseCouponQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponQuery.php @@ -724,4 +724,69 @@ abstract class BaseCouponQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CouponQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CouponPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CouponQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CouponQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CouponQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CouponPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CouponQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CouponPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CouponQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CouponPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCouponRule.php b/core/lib/Thelia/Model/om/BaseCouponRule.php index 0a06eef8b..95d552a58 100644 --- a/core/lib/Thelia/Model/om/BaseCouponRule.php +++ b/core/lib/Thelia/Model/om/BaseCouponRule.php @@ -572,8 +572,19 @@ abstract class BaseCouponRule extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CouponRulePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CouponRulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CouponRulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1262,4 +1273,18 @@ abstract class BaseCouponRule extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CouponRule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CouponRulePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php index 39d5e507e..5258ebc08 100644 --- a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php @@ -589,4 +589,69 @@ abstract class BaseCouponRuleQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CouponRulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponRulePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponRulePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CouponRulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CouponRulePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CouponRuleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CouponRulePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/om/BaseCurrency.php index 2f143f6fd..2e7958d96 100644 --- a/core/lib/Thelia/Model/om/BaseCurrency.php +++ b/core/lib/Thelia/Model/om/BaseCurrency.php @@ -80,10 +80,10 @@ abstract class BaseCurrency extends BaseObject implements Persistent protected $rate; /** - * The value for the default_utility field. + * The value for the by_default field. * @var int */ - protected $default_utility; + protected $by_default; /** * The value for the created_at field. @@ -174,13 +174,13 @@ abstract class BaseCurrency extends BaseObject implements Persistent } /** - * Get the [default_utility] column value. + * Get the [by_default] column value. * * @return int */ - public function getDefaultUtility() + public function getByDefault() { - return $this->default_utility; + return $this->by_default; } /** @@ -363,25 +363,25 @@ abstract class BaseCurrency extends BaseObject implements Persistent } // setRate() /** - * Set the value of [default_utility] column. + * Set the value of [by_default] column. * * @param int $v new value * @return Currency The current object (for fluent API support) */ - public function setDefaultUtility($v) + public function setByDefault($v) { if ($v !== null) { $v = (int) $v; } - if ($this->default_utility !== $v) { - $this->default_utility = $v; - $this->modifiedColumns[] = CurrencyPeer::DEFAULT_UTILITY; + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = CurrencyPeer::BY_DEFAULT; } return $this; - } // setDefaultUtility() + } // setByDefault() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -466,7 +466,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->symbol = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->rate = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; - $this->default_utility = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->by_default = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->resetModified(); @@ -613,8 +613,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CurrencyPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -724,8 +735,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($this->isColumnModified(CurrencyPeer::RATE)) { $modifiedColumns[':p' . $index++] = '`RATE`'; } - if ($this->isColumnModified(CurrencyPeer::DEFAULT_UTILITY)) { - $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`'; + if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; } if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; @@ -759,8 +770,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent case '`RATE`': $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); break; - case '`DEFAULT_UTILITY`': - $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT); + case '`BY_DEFAULT`': + $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; case '`CREATED_AT`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); @@ -926,7 +937,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent return $this->getRate(); break; case 5: - return $this->getDefaultUtility(); + return $this->getByDefault(); break; case 6: return $this->getCreatedAt(); @@ -968,7 +979,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $keys[2] => $this->getCode(), $keys[3] => $this->getSymbol(), $keys[4] => $this->getRate(), - $keys[5] => $this->getDefaultUtility(), + $keys[5] => $this->getByDefault(), $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); @@ -1026,7 +1037,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->setRate($value); break; case 5: - $this->setDefaultUtility($value); + $this->setByDefault($value); break; case 6: $this->setCreatedAt($value); @@ -1063,7 +1074,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setSymbol($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDefaultUtility($arr[$keys[5]]); + if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); } @@ -1082,7 +1093,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($this->isColumnModified(CurrencyPeer::CODE)) $criteria->add(CurrencyPeer::CODE, $this->code); if ($this->isColumnModified(CurrencyPeer::SYMBOL)) $criteria->add(CurrencyPeer::SYMBOL, $this->symbol); if ($this->isColumnModified(CurrencyPeer::RATE)) $criteria->add(CurrencyPeer::RATE, $this->rate); - if ($this->isColumnModified(CurrencyPeer::DEFAULT_UTILITY)) $criteria->add(CurrencyPeer::DEFAULT_UTILITY, $this->default_utility); + if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) $criteria->add(CurrencyPeer::BY_DEFAULT, $this->by_default); if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) $criteria->add(CurrencyPeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) $criteria->add(CurrencyPeer::UPDATED_AT, $this->updated_at); @@ -1152,7 +1163,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $copyObj->setCode($this->getCode()); $copyObj->setSymbol($this->getSymbol()); $copyObj->setRate($this->getRate()); - $copyObj->setDefaultUtility($this->getDefaultUtility()); + $copyObj->setByDefault($this->getByDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1552,7 +1563,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->code = null; $this->symbol = null; $this->rate = null; - $this->default_utility = null; + $this->by_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1608,4 +1619,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Currency The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CurrencyPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php index 698b5e9e0..11ec01f8f 100644 --- a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php +++ b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php @@ -60,8 +60,8 @@ abstract class BaseCurrencyPeer /** the column name for the RATE field */ const RATE = 'currency.RATE'; - /** the column name for the DEFAULT_UTILITY field */ - const DEFAULT_UTILITY = 'currency.DEFAULT_UTILITY'; + /** 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'; @@ -88,11 +88,11 @@ abstract class BaseCurrencyPeer * e.g. CurrencyPeer::$fieldNames[CurrencyPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Code', 'Symbol', 'Rate', 'DefaultUtility', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'defaultUtility', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID, CurrencyPeer::NAME, CurrencyPeer::CODE, CurrencyPeer::SYMBOL, CurrencyPeer::RATE, CurrencyPeer::DEFAULT_UTILITY, CurrencyPeer::CREATED_AT, CurrencyPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'DEFAULT_UTILITY', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'default_utility', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID, CurrencyPeer::NAME, CurrencyPeer::CODE, CurrencyPeer::SYMBOL, CurrencyPeer::RATE, CurrencyPeer::BY_DEFAULT, CurrencyPeer::CREATED_AT, CurrencyPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -103,11 +103,11 @@ abstract class BaseCurrencyPeer * e.g. CurrencyPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'DefaultUtility' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'defaultUtility' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID => 0, CurrencyPeer::NAME => 1, CurrencyPeer::CODE => 2, CurrencyPeer::SYMBOL => 3, CurrencyPeer::RATE => 4, CurrencyPeer::DEFAULT_UTILITY => 5, CurrencyPeer::CREATED_AT => 6, CurrencyPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'DEFAULT_UTILITY' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'default_utility' => 5, 'created_at' => 6, 'updated_at' => 7, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID => 0, CurrencyPeer::NAME => 1, CurrencyPeer::CODE => 2, CurrencyPeer::SYMBOL => 3, CurrencyPeer::RATE => 4, CurrencyPeer::BY_DEFAULT => 5, CurrencyPeer::CREATED_AT => 6, CurrencyPeer::UPDATED_AT => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -187,7 +187,7 @@ abstract class BaseCurrencyPeer $criteria->addSelectColumn(CurrencyPeer::CODE); $criteria->addSelectColumn(CurrencyPeer::SYMBOL); $criteria->addSelectColumn(CurrencyPeer::RATE); - $criteria->addSelectColumn(CurrencyPeer::DEFAULT_UTILITY); + $criteria->addSelectColumn(CurrencyPeer::BY_DEFAULT); $criteria->addSelectColumn(CurrencyPeer::CREATED_AT); $criteria->addSelectColumn(CurrencyPeer::UPDATED_AT); } else { @@ -196,7 +196,7 @@ abstract class BaseCurrencyPeer $criteria->addSelectColumn($alias . '.CODE'); $criteria->addSelectColumn($alias . '.SYMBOL'); $criteria->addSelectColumn($alias . '.RATE'); - $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY'); + $criteria->addSelectColumn($alias . '.BY_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php index e78de4a09..819109902 100644 --- a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php +++ b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php @@ -27,7 +27,7 @@ use Thelia\Model\Order; * @method CurrencyQuery orderByCode($order = Criteria::ASC) Order by the code column * @method CurrencyQuery orderBySymbol($order = Criteria::ASC) Order by the symbol column * @method CurrencyQuery orderByRate($order = Criteria::ASC) Order by the rate column - * @method CurrencyQuery orderByDefaultUtility($order = Criteria::ASC) Order by the default_utility column + * @method CurrencyQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column * @method CurrencyQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method CurrencyQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -36,7 +36,7 @@ use Thelia\Model\Order; * @method CurrencyQuery groupByCode() Group by the code column * @method CurrencyQuery groupBySymbol() Group by the symbol column * @method CurrencyQuery groupByRate() Group by the rate column - * @method CurrencyQuery groupByDefaultUtility() Group by the default_utility column + * @method CurrencyQuery groupByByDefault() Group by the by_default column * @method CurrencyQuery groupByCreatedAt() Group by the created_at column * @method CurrencyQuery groupByUpdatedAt() Group by the updated_at column * @@ -56,7 +56,7 @@ use Thelia\Model\Order; * @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 * @method Currency findOneByRate(double $rate) Return the first Currency filtered by the rate column - * @method Currency findOneByDefaultUtility(int $default_utility) Return the first Currency filtered by the default_utility column + * @method Currency findOneByByDefault(int $by_default) Return the first Currency filtered by the by_default column * @method Currency findOneByCreatedAt(string $created_at) Return the first Currency filtered by the created_at column * @method Currency findOneByUpdatedAt(string $updated_at) Return the first Currency filtered by the updated_at column * @@ -65,7 +65,7 @@ use Thelia\Model\Order; * @method array findByCode(string $code) Return Currency objects filtered by the code column * @method array findBySymbol(string $symbol) Return Currency objects filtered by the symbol column * @method array findByRate(double $rate) Return Currency objects filtered by the rate column - * @method array findByDefaultUtility(int $default_utility) Return Currency objects filtered by the default_utility column + * @method array findByByDefault(int $by_default) Return Currency objects filtered by the by_default column * @method array findByCreatedAt(string $created_at) Return Currency objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return Currency objects filtered by the updated_at column * @@ -157,7 +157,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `NAME`, `CODE`, `SYMBOL`, `RATE`, `DEFAULT_UTILITY`, `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); @@ -402,16 +402,16 @@ abstract class BaseCurrencyQuery extends ModelCriteria } /** - * Filter the query on the default_utility column + * Filter the query on the by_default column * * Example usage: * - * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234 - * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34) - * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12 + * $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 * * - * @param mixed $defaultUtility The value to use as filter. + * @param mixed $byDefault The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -419,16 +419,16 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * @return CurrencyQuery The current query, for fluid interface */ - public function filterByDefaultUtility($defaultUtility = null, $comparison = null) + public function filterByByDefault($byDefault = null, $comparison = null) { - if (is_array($defaultUtility)) { + if (is_array($byDefault)) { $useMinMax = false; - if (isset($defaultUtility['min'])) { - $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL); + if (isset($byDefault['min'])) { + $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($defaultUtility['max'])) { - $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL); + if (isset($byDefault['max'])) { + $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -439,7 +439,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::DEFAULT_UTILITY, $defaultUtility, $comparison); + return $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault, $comparison); } /** @@ -618,4 +618,69 @@ abstract class BaseCurrencyQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CurrencyPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CurrencyPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CurrencyPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CurrencyPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CurrencyPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CurrencyQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CurrencyPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/om/BaseCustomer.php index 0a9096d5f..f86b8cabf 100644 --- a/core/lib/Thelia/Model/om/BaseCustomer.php +++ b/core/lib/Thelia/Model/om/BaseCustomer.php @@ -1252,8 +1252,19 @@ abstract class BaseCustomer extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CustomerPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CustomerPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CustomerPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -2875,4 +2886,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Customer The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CustomerPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/om/BaseCustomerQuery.php index 39b21ba14..f719d555b 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerQuery.php @@ -1332,4 +1332,69 @@ abstract class BaseCustomerQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CustomerQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CustomerPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CustomerQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CustomerQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CustomerQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CustomerPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CustomerQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CustomerQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/om/BaseCustomerTitle.php index 6a91ebd96..d6eafbb8f 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitle.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitle.php @@ -60,11 +60,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent protected $id; /** - * The value for the default_utility field. + * The value for the by_default field. * Note: this column has a database default value of: 0 * @var int */ - protected $default_utility; + protected $by_default; /** * The value for the position field. @@ -84,18 +84,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|Address[] Collection to store aggregation of Address objects. - */ - protected $collAddresss; - protected $collAddresssPartial; - /** * @var PropelObjectCollection|Customer[] Collection to store aggregation of Customer objects. */ protected $collCustomers; protected $collCustomersPartial; + /** + * @var PropelObjectCollection|Address[] Collection to store aggregation of Address objects. + */ + protected $collAddresss; + protected $collAddresssPartial; + /** * @var PropelObjectCollection|CustomerTitleDesc[] Collection to store aggregation of CustomerTitleDesc objects. */ @@ -120,13 +120,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $addresssScheduledForDeletion = null; + protected $customersScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $customersScheduledForDeletion = null; + protected $addresssScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -142,7 +142,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function applyDefaultValues() { - $this->default_utility = 0; + $this->by_default = 0; } /** @@ -166,13 +166,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * Get the [default_utility] column value. + * Get the [by_default] column value. * * @return int */ - public function getDefaultUtility() + public function getByDefault() { - return $this->default_utility; + return $this->by_default; } /** @@ -281,25 +281,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } // setId() /** - * Set the value of [default_utility] column. + * Set the value of [by_default] column. * * @param int $v new value * @return CustomerTitle The current object (for fluent API support) */ - public function setDefaultUtility($v) + public function setByDefault($v) { if ($v !== null) { $v = (int) $v; } - if ($this->default_utility !== $v) { - $this->default_utility = $v; - $this->modifiedColumns[] = CustomerTitlePeer::DEFAULT_UTILITY; + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = CustomerTitlePeer::BY_DEFAULT; } return $this; - } // setDefaultUtility() + } // setByDefault() /** * Set the value of [position] column. @@ -378,7 +378,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - if ($this->default_utility !== 0) { + if ($this->by_default !== 0) { return false; } @@ -405,7 +405,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->default_utility = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->by_default = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; $this->position = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; @@ -479,10 +479,10 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collAddresss = null; - $this->collCustomers = null; + $this->collAddresss = null; + $this->collCustomerTitleDescs = null; } // if (deep) @@ -557,8 +557,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -609,24 +620,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->resetModified(); } - if ($this->addresssScheduledForDeletion !== null) { - if (!$this->addresssScheduledForDeletion->isEmpty()) { - foreach ($this->addresssScheduledForDeletion as $address) { - // need to save related object because we set the relation to null - $address->save($con); - } - $this->addresssScheduledForDeletion = null; - } - } - - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->customersScheduledForDeletion !== null) { if (!$this->customersScheduledForDeletion->isEmpty()) { foreach ($this->customersScheduledForDeletion as $customer) { @@ -645,6 +638,24 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } + if ($this->addresssScheduledForDeletion !== null) { + if (!$this->addresssScheduledForDeletion->isEmpty()) { + foreach ($this->addresssScheduledForDeletion as $address) { + // need to save related object because we set the relation to null + $address->save($con); + } + $this->addresssScheduledForDeletion = null; + } + } + + if ($this->collAddresss !== null) { + foreach ($this->collAddresss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->customerTitleDescsScheduledForDeletion !== null) { if (!$this->customerTitleDescsScheduledForDeletion->isEmpty()) { CustomerTitleDescQuery::create() @@ -691,8 +702,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($this->isColumnModified(CustomerTitlePeer::ID)) { $modifiedColumns[':p' . $index++] = '`ID`'; } - if ($this->isColumnModified(CustomerTitlePeer::DEFAULT_UTILITY)) { - $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`'; + if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; } if ($this->isColumnModified(CustomerTitlePeer::POSITION)) { $modifiedColumns[':p' . $index++] = '`POSITION`'; @@ -717,8 +728,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent case '`ID`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`DEFAULT_UTILITY`': - $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT); + case '`BY_DEFAULT`': + $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; case '`POSITION`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR); @@ -828,16 +839,16 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { + if ($this->collCustomers !== null) { + foreach ($this->collCustomers as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collCustomers !== null) { - foreach ($this->collCustomers as $referrerFK) { + if ($this->collAddresss !== null) { + foreach ($this->collAddresss as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -891,7 +902,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return $this->getId(); break; case 1: - return $this->getDefaultUtility(); + return $this->getByDefault(); break; case 2: return $this->getPosition(); @@ -932,18 +943,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $keys = CustomerTitlePeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getDefaultUtility(), + $keys[1] => $this->getByDefault(), $keys[2] => $this->getPosition(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collAddresss) { - $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collCustomers) { $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collAddresss) { + $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCustomerTitleDescs) { $result['CustomerTitleDescs'] = $this->collCustomerTitleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -985,7 +996,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->setId($value); break; case 1: - $this->setDefaultUtility($value); + $this->setByDefault($value); break; case 2: $this->setPosition($value); @@ -1021,7 +1032,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $keys = CustomerTitlePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDefaultUtility($arr[$keys[1]]); + if (array_key_exists($keys[1], $arr)) $this->setByDefault($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); @@ -1037,7 +1048,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); if ($this->isColumnModified(CustomerTitlePeer::ID)) $criteria->add(CustomerTitlePeer::ID, $this->id); - if ($this->isColumnModified(CustomerTitlePeer::DEFAULT_UTILITY)) $criteria->add(CustomerTitlePeer::DEFAULT_UTILITY, $this->default_utility); + if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) $criteria->add(CustomerTitlePeer::BY_DEFAULT, $this->by_default); if ($this->isColumnModified(CustomerTitlePeer::POSITION)) $criteria->add(CustomerTitlePeer::POSITION, $this->position); if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) $criteria->add(CustomerTitlePeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) $criteria->add(CustomerTitlePeer::UPDATED_AT, $this->updated_at); @@ -1104,7 +1115,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setDefaultUtility($this->getDefaultUtility()); + $copyObj->setByDefault($this->getByDefault()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1116,18 +1127,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getAddresss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAddress($relObj->copy($deepCopy)); - } - } - foreach ($this->getCustomers() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCustomer($relObj->copy($deepCopy)); } } + foreach ($this->getAddresss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAddress($relObj->copy($deepCopy)); + } + } + foreach ($this->getCustomerTitleDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCustomerTitleDesc($relObj->copy($deepCopy)); @@ -1195,17 +1206,224 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('Address' == $relationName) { - $this->initAddresss(); - } if ('Customer' == $relationName) { $this->initCustomers(); } + if ('Address' == $relationName) { + $this->initAddresss(); + } if ('CustomerTitleDesc' == $relationName) { $this->initCustomerTitleDescs(); } } + /** + * Clears out the collCustomers collection + * + * 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 + * @see addCustomers() + */ + public function clearCustomers() + { + $this->collCustomers = null; // important to set this to null since that means it is uninitialized + $this->collCustomersPartial = null; + } + + /** + * reset is the collCustomers collection loaded partially + * + * @return void + */ + public function resetPartialCustomers($v = true) + { + $this->collCustomersPartial = $v; + } + + /** + * Initializes the collCustomers collection. + * + * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCustomers($overrideExisting = true) + { + if (null !== $this->collCustomers && !$overrideExisting) { + return; + } + $this->collCustomers = new PropelObjectCollection(); + $this->collCustomers->setModel('Customer'); + } + + /** + * Gets an array of Customer objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this CustomerTitle is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Customer[] List of Customer objects + * @throws PropelException + */ + public function getCustomers($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCustomersPartial && !$this->isNew(); + if (null === $this->collCustomers || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomers) { + // return empty collection + $this->initCustomers(); + } else { + $collCustomers = CustomerQuery::create(null, $criteria) + ->filterByCustomerTitle($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCustomersPartial && count($collCustomers)) { + $this->initCustomers(false); + + foreach($collCustomers as $obj) { + if (false == $this->collCustomers->contains($obj)) { + $this->collCustomers->append($obj); + } + } + + $this->collCustomersPartial = true; + } + + return $collCustomers; + } + + if($partial && $this->collCustomers) { + foreach($this->collCustomers as $obj) { + if($obj->isNew()) { + $collCustomers[] = $obj; + } + } + } + + $this->collCustomers = $collCustomers; + $this->collCustomersPartial = false; + } + } + + return $this->collCustomers; + } + + /** + * Sets a collection of Customer objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $customers A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setCustomers(PropelCollection $customers, PropelPDO $con = null) + { + $this->customersScheduledForDeletion = $this->getCustomers(new Criteria(), $con)->diff($customers); + + foreach ($this->customersScheduledForDeletion as $customerRemoved) { + $customerRemoved->setCustomerTitle(null); + } + + $this->collCustomers = null; + foreach ($customers as $customer) { + $this->addCustomer($customer); + } + + $this->collCustomers = $customers; + $this->collCustomersPartial = false; + } + + /** + * Returns the number of related Customer objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Customer objects. + * @throws PropelException + */ + public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCustomersPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Customer object to this object + * through the Customer foreign key attribute. + * + * @param Customer $l Customer + * @return CustomerTitle The current object (for fluent API support) + */ + public function addCustomer(Customer $l) + { + if ($this->collCustomers === null) { + $this->initCustomers(); + $this->collCustomersPartial = true; + } + if (!$this->collCustomers->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddCustomer($l); + } + + return $this; + } + + /** + * @param Customer $customer The customer object to add. + */ + protected function doAddCustomer($customer) + { + $this->collCustomers[]= $customer; + $customer->setCustomerTitle($this); + } + + /** + * @param Customer $customer The customer object to remove. + */ + public function removeCustomer($customer) + { + if ($this->getCustomers()->contains($customer)) { + $this->collCustomers->remove($this->collCustomers->search($customer)); + if (null === $this->customersScheduledForDeletion) { + $this->customersScheduledForDeletion = clone $this->collCustomers; + $this->customersScheduledForDeletion->clear(); + } + $this->customersScheduledForDeletion[]= $customer; + $customer->setCustomerTitle(null); + } + } + /** * Clears out the collAddresss collection * @@ -1438,213 +1656,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return $this->getAddresss($query, $con); } - /** - * Clears out the collCustomers collection - * - * 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 - * @see addCustomers() - */ - public function clearCustomers() - { - $this->collCustomers = null; // important to set this to null since that means it is uninitialized - $this->collCustomersPartial = null; - } - - /** - * reset is the collCustomers collection loaded partially - * - * @return void - */ - public function resetPartialCustomers($v = true) - { - $this->collCustomersPartial = $v; - } - - /** - * Initializes the collCustomers collection. - * - * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCustomers($overrideExisting = true) - { - if (null !== $this->collCustomers && !$overrideExisting) { - return; - } - $this->collCustomers = new PropelObjectCollection(); - $this->collCustomers->setModel('Customer'); - } - - /** - * Gets an array of Customer objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this CustomerTitle is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Customer[] List of Customer objects - * @throws PropelException - */ - public function getCustomers($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - if (null === $this->collCustomers || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomers) { - // return empty collection - $this->initCustomers(); - } else { - $collCustomers = CustomerQuery::create(null, $criteria) - ->filterByCustomerTitle($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCustomersPartial && count($collCustomers)) { - $this->initCustomers(false); - - foreach($collCustomers as $obj) { - if (false == $this->collCustomers->contains($obj)) { - $this->collCustomers->append($obj); - } - } - - $this->collCustomersPartial = true; - } - - return $collCustomers; - } - - if($partial && $this->collCustomers) { - foreach($this->collCustomers as $obj) { - if($obj->isNew()) { - $collCustomers[] = $obj; - } - } - } - - $this->collCustomers = $collCustomers; - $this->collCustomersPartial = false; - } - } - - return $this->collCustomers; - } - - /** - * Sets a collection of Customer objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $customers A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setCustomers(PropelCollection $customers, PropelPDO $con = null) - { - $this->customersScheduledForDeletion = $this->getCustomers(new Criteria(), $con)->diff($customers); - - foreach ($this->customersScheduledForDeletion as $customerRemoved) { - $customerRemoved->setCustomerTitle(null); - } - - $this->collCustomers = null; - foreach ($customers as $customer) { - $this->addCustomer($customer); - } - - $this->collCustomers = $customers; - $this->collCustomersPartial = false; - } - - /** - * Returns the number of related Customer objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Customer objects. - * @throws PropelException - */ - public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Customer object to this object - * through the Customer foreign key attribute. - * - * @param Customer $l Customer - * @return CustomerTitle The current object (for fluent API support) - */ - public function addCustomer(Customer $l) - { - if ($this->collCustomers === null) { - $this->initCustomers(); - $this->collCustomersPartial = true; - } - if (!$this->collCustomers->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddCustomer($l); - } - - return $this; - } - - /** - * @param Customer $customer The customer object to add. - */ - protected function doAddCustomer($customer) - { - $this->collCustomers[]= $customer; - $customer->setCustomerTitle($this); - } - - /** - * @param Customer $customer The customer object to remove. - */ - public function removeCustomer($customer) - { - if ($this->getCustomers()->contains($customer)) { - $this->collCustomers->remove($this->collCustomers->search($customer)); - if (null === $this->customersScheduledForDeletion) { - $this->customersScheduledForDeletion = clone $this->collCustomers; - $this->customersScheduledForDeletion->clear(); - } - $this->customersScheduledForDeletion[]= $customer; - $customer->setCustomerTitle(null); - } - } - /** * Clears out the collCustomerTitleDescs collection * @@ -1858,7 +1869,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent public function clear() { $this->id = null; - $this->default_utility = null; + $this->by_default = null; $this->position = null; $this->created_at = null; $this->updated_at = null; @@ -1883,13 +1894,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collAddresss) { - foreach ($this->collAddresss as $o) { + if ($this->collCustomers) { + foreach ($this->collCustomers as $o) { $o->clearAllReferences($deep); } } - if ($this->collCustomers) { - foreach ($this->collCustomers as $o) { + if ($this->collAddresss) { + foreach ($this->collAddresss as $o) { $o->clearAllReferences($deep); } } @@ -1900,14 +1911,14 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } // if ($deep) - if ($this->collAddresss instanceof PropelCollection) { - $this->collAddresss->clearIterator(); - } - $this->collAddresss = null; if ($this->collCustomers instanceof PropelCollection) { $this->collCustomers->clearIterator(); } $this->collCustomers = null; + if ($this->collAddresss instanceof PropelCollection) { + $this->collAddresss->clearIterator(); + } + $this->collAddresss = null; if ($this->collCustomerTitleDescs instanceof PropelCollection) { $this->collCustomerTitleDescs->clearIterator(); } @@ -1934,4 +1945,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CustomerTitle The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CustomerTitlePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php index e73e04c23..2e9a23a27 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDesc.php @@ -572,8 +572,19 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CustomerTitleDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CustomerTitleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CustomerTitleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1262,4 +1273,18 @@ abstract class BaseCustomerTitleDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return CustomerTitleDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CustomerTitleDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php index ff7c9fbec..fa4ce5bc8 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleDescQuery.php @@ -577,4 +577,69 @@ abstract class BaseCustomerTitleDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CustomerTitleDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTitleDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTitleDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CustomerTitleDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTitleDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CustomerTitleDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTitleDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php index ebe4d868d..afd255021 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php @@ -49,8 +49,8 @@ abstract class BaseCustomerTitlePeer /** the column name for the ID field */ const ID = 'customer_title.ID'; - /** the column name for the DEFAULT_UTILITY field */ - const DEFAULT_UTILITY = 'customer_title.DEFAULT_UTILITY'; + /** 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'; @@ -80,11 +80,11 @@ abstract class BaseCustomerTitlePeer * e.g. CustomerTitlePeer::$fieldNames[CustomerTitlePeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'DefaultUtility', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'defaultUtility', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID, CustomerTitlePeer::DEFAULT_UTILITY, CustomerTitlePeer::POSITION, CustomerTitlePeer::CREATED_AT, CustomerTitlePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DEFAULT_UTILITY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'default_utility', 'position', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'byDefault', 'position', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID, CustomerTitlePeer::BY_DEFAULT, CustomerTitlePeer::POSITION, CustomerTitlePeer::CREATED_AT, CustomerTitlePeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'by_default', 'position', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); @@ -95,11 +95,11 @@ abstract class BaseCustomerTitlePeer * e.g. CustomerTitlePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DefaultUtility' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'defaultUtility' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID => 0, CustomerTitlePeer::DEFAULT_UTILITY => 1, CustomerTitlePeer::POSITION => 2, CustomerTitlePeer::CREATED_AT => 3, CustomerTitlePeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DEFAULT_UTILITY' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'default_utility' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ByDefault' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'byDefault' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID => 0, CustomerTitlePeer::BY_DEFAULT => 1, CustomerTitlePeer::POSITION => 2, CustomerTitlePeer::CREATED_AT => 3, CustomerTitlePeer::UPDATED_AT => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'BY_DEFAULT' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'by_default' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); @@ -175,13 +175,13 @@ abstract class BaseCustomerTitlePeer { if (null === $alias) { $criteria->addSelectColumn(CustomerTitlePeer::ID); - $criteria->addSelectColumn(CustomerTitlePeer::DEFAULT_UTILITY); + $criteria->addSelectColumn(CustomerTitlePeer::BY_DEFAULT); $criteria->addSelectColumn(CustomerTitlePeer::POSITION); $criteria->addSelectColumn(CustomerTitlePeer::CREATED_AT); $criteria->addSelectColumn(CustomerTitlePeer::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY'); + $criteria->addSelectColumn($alias . '.BY_DEFAULT'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php index 0e0ac3100..9d962cbe2 100644 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php +++ b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php @@ -25,13 +25,13 @@ use Thelia\Model\CustomerTitleQuery; * * * @method CustomerTitleQuery orderById($order = Criteria::ASC) Order by the id column - * @method CustomerTitleQuery orderByDefaultUtility($order = Criteria::ASC) Order by the default_utility column + * @method CustomerTitleQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column * @method CustomerTitleQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method CustomerTitleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method CustomerTitleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method CustomerTitleQuery groupById() Group by the id column - * @method CustomerTitleQuery groupByDefaultUtility() Group by the default_utility column + * @method CustomerTitleQuery groupByByDefault() Group by the by_default column * @method CustomerTitleQuery groupByPosition() Group by the position column * @method CustomerTitleQuery groupByCreatedAt() Group by the created_at column * @method CustomerTitleQuery groupByUpdatedAt() Group by the updated_at column @@ -40,14 +40,14 @@ use Thelia\Model\CustomerTitleQuery; * @method CustomerTitleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CustomerTitleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method CustomerTitleQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation - * @method CustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation - * @method CustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation - * * @method CustomerTitleQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation * @method CustomerTitleQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation * @method CustomerTitleQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation * + * @method CustomerTitleQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation + * @method CustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation + * @method CustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation + * * @method CustomerTitleQuery leftJoinCustomerTitleDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitleDesc relation * @method CustomerTitleQuery rightJoinCustomerTitleDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitleDesc relation * @method CustomerTitleQuery innerJoinCustomerTitleDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitleDesc relation @@ -56,13 +56,13 @@ use Thelia\Model\CustomerTitleQuery; * @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 findOneByDefaultUtility(int $default_utility) Return the first CustomerTitle filtered by the default_utility 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 * @method CustomerTitle findOneByUpdatedAt(string $updated_at) Return the first CustomerTitle filtered by the updated_at column * * @method array findById(int $id) Return CustomerTitle objects filtered by the id column - * @method array findByDefaultUtility(int $default_utility) Return CustomerTitle objects filtered by the default_utility column + * @method array findByByDefault(int $by_default) Return CustomerTitle objects filtered by the by_default column * @method array findByPosition(string $position) Return CustomerTitle objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return CustomerTitle objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return CustomerTitle objects filtered by the updated_at column @@ -155,7 +155,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `DEFAULT_UTILITY`, `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); @@ -272,16 +272,16 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } /** - * Filter the query on the default_utility column + * Filter the query on the by_default column * * Example usage: * - * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234 - * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34) - * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12 + * $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 * * - * @param mixed $defaultUtility The value to use as filter. + * @param mixed $byDefault The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -289,16 +289,16 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @return CustomerTitleQuery The current query, for fluid interface */ - public function filterByDefaultUtility($defaultUtility = null, $comparison = null) + public function filterByByDefault($byDefault = null, $comparison = null) { - if (is_array($defaultUtility)) { + if (is_array($byDefault)) { $useMinMax = false; - if (isset($defaultUtility['min'])) { - $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL); + if (isset($byDefault['min'])) { + $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($defaultUtility['max'])) { - $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL); + if (isset($byDefault['max'])) { + $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -309,7 +309,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::DEFAULT_UTILITY, $defaultUtility, $comparison); + return $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault, $comparison); } /** @@ -427,80 +427,6 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related Address object - * - * @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. - */ - public function filterByAddress($address, $comparison = null) - { - if ($address instanceof Address) { - return $this - ->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison); - } elseif ($address instanceof PropelObjectCollection) { - return $this - ->useAddressQuery() - ->filterByPrimaryKeys($address->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Address relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Address'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Address'); - } - - return $this; - } - - /** - * Use the Address relation Address object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query - */ - public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinAddress($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery'); - } - /** * Filter the query by a related Customer object * @@ -575,6 +501,80 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); } + /** + * Filter the query by a related Address object + * + * @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. + */ + public function filterByAddress($address, $comparison = null) + { + if ($address instanceof Address) { + return $this + ->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison); + } elseif ($address instanceof PropelObjectCollection) { + return $this + ->useAddressQuery() + ->filterByPrimaryKeys($address->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Address relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Address'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Address'); + } + + return $this; + } + + /** + * Use the Address relation Address object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query + */ + public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinAddress($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery'); + } + /** * Filter the query by a related CustomerTitleDesc object * @@ -665,4 +665,69 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTitlePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTitlePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTitlePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return CustomerTitleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTitlePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseDelivzone.php b/core/lib/Thelia/Model/om/BaseDelivzone.php index a1e31aa18..1ae77190e 100644 --- a/core/lib/Thelia/Model/om/BaseDelivzone.php +++ b/core/lib/Thelia/Model/om/BaseDelivzone.php @@ -496,8 +496,19 @@ abstract class BaseDelivzone extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(DelivzonePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(DelivzonePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(DelivzonePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1152,4 +1163,18 @@ abstract class BaseDelivzone extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Delivzone The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = DelivzonePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php index abfaf373d..9f6bb4e06 100644 --- a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php +++ b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php @@ -511,4 +511,69 @@ abstract class BaseDelivzoneQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(DelivzonePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(DelivzonePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(DelivzonePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(DelivzonePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return DelivzoneQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(DelivzonePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/om/BaseDocument.php index cad17c959..31b9c94fd 100644 --- a/core/lib/Thelia/Model/om/BaseDocument.php +++ b/core/lib/Thelia/Model/om/BaseDocument.php @@ -711,8 +711,19 @@ abstract class BaseDocument extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(DocumentPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(DocumentPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(DocumentPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1905,4 +1916,18 @@ abstract class BaseDocument extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Document The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = DocumentPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseDocumentDesc.php b/core/lib/Thelia/Model/om/BaseDocumentDesc.php index 3c341edc7..74787a12e 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentDesc.php +++ b/core/lib/Thelia/Model/om/BaseDocumentDesc.php @@ -610,8 +610,19 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(DocumentDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(DocumentDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(DocumentDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseDocumentDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return DocumentDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = DocumentDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php index 5d1597689..625df55ab 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseDocumentDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseDocumentDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(DocumentDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(DocumentDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(DocumentDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(DocumentDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(DocumentDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return DocumentDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(DocumentDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/om/BaseDocumentQuery.php index ce4457035..0afccfc7f 100644 --- a/core/lib/Thelia/Model/om/BaseDocumentQuery.php +++ b/core/lib/Thelia/Model/om/BaseDocumentQuery.php @@ -1019,4 +1019,69 @@ abstract class BaseDocumentQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return DocumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(DocumentPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return DocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(DocumentPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return DocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(DocumentPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return DocumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(DocumentPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return DocumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(DocumentPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return DocumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(DocumentPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/om/BaseFeature.php index 773ad7232..347f24e25 100644 --- a/core/lib/Thelia/Model/om/BaseFeature.php +++ b/core/lib/Thelia/Model/om/BaseFeature.php @@ -86,30 +86,30 @@ abstract class BaseFeature extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|FeatureAv[] Collection to store aggregation of FeatureAv objects. - */ - protected $collFeatureAvs; - protected $collFeatureAvsPartial; - - /** - * @var PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects. - */ - protected $collFeatureCategorys; - protected $collFeatureCategorysPartial; - /** * @var PropelObjectCollection|FeatureDesc[] Collection to store aggregation of FeatureDesc objects. */ protected $collFeatureDescs; protected $collFeatureDescsPartial; + /** + * @var PropelObjectCollection|FeatureAv[] Collection to store aggregation of FeatureAv objects. + */ + protected $collFeatureAvs; + protected $collFeatureAvsPartial; + /** * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects. */ protected $collFeatureProds; protected $collFeatureProdsPartial; + /** + * @var PropelObjectCollection|FeatureCategory[] Collection to store aggregation of FeatureCategory objects. + */ + protected $collFeatureCategorys; + protected $collFeatureCategorysPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -124,30 +124,30 @@ abstract class BaseFeature extends BaseObject implements Persistent */ protected $alreadyInValidation = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $featureAvsScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $featureCategorysScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ protected $featureDescsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $featureAvsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ protected $featureProdsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $featureCategorysScheduledForDeletion = null; + /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -493,14 +493,14 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collFeatureAvs = null; - - $this->collFeatureCategorys = null; - $this->collFeatureDescs = null; + $this->collFeatureAvs = null; + $this->collFeatureProds = null; + $this->collFeatureCategorys = null; + } // if (deep) } @@ -573,8 +573,19 @@ abstract class BaseFeature extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeaturePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeaturePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeaturePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -625,40 +636,6 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->resetModified(); } - if ($this->featureAvsScheduledForDeletion !== null) { - if (!$this->featureAvsScheduledForDeletion->isEmpty()) { - FeatureAvQuery::create() - ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureAvsScheduledForDeletion = null; - } - } - - if ($this->collFeatureAvs !== null) { - foreach ($this->collFeatureAvs as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureCategorysScheduledForDeletion !== null) { - if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureCategorysScheduledForDeletion = null; - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->featureDescsScheduledForDeletion !== null) { if (!$this->featureDescsScheduledForDeletion->isEmpty()) { FeatureDescQuery::create() @@ -676,6 +653,23 @@ abstract class BaseFeature extends BaseObject implements Persistent } } + if ($this->featureAvsScheduledForDeletion !== null) { + if (!$this->featureAvsScheduledForDeletion->isEmpty()) { + FeatureAvQuery::create() + ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->featureAvsScheduledForDeletion = null; + } + } + + if ($this->collFeatureAvs !== null) { + foreach ($this->collFeatureAvs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->featureProdsScheduledForDeletion !== null) { if (!$this->featureProdsScheduledForDeletion->isEmpty()) { FeatureProdQuery::create() @@ -693,6 +687,23 @@ abstract class BaseFeature extends BaseObject implements Persistent } } + if ($this->featureCategorysScheduledForDeletion !== null) { + if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { + FeatureCategoryQuery::create() + ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->featureCategorysScheduledForDeletion = null; + } + } + + if ($this->collFeatureCategorys !== null) { + foreach ($this->collFeatureCategorys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -859,22 +870,6 @@ abstract class BaseFeature extends BaseObject implements Persistent } - if ($this->collFeatureAvs !== null) { - foreach ($this->collFeatureAvs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collFeatureDescs !== null) { foreach ($this->collFeatureDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -883,6 +878,14 @@ abstract class BaseFeature extends BaseObject implements Persistent } } + if ($this->collFeatureAvs !== null) { + foreach ($this->collFeatureAvs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collFeatureProds !== null) { foreach ($this->collFeatureProds as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -891,6 +894,14 @@ abstract class BaseFeature extends BaseObject implements Persistent } } + if ($this->collFeatureCategorys !== null) { + foreach ($this->collFeatureCategorys as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + $this->alreadyInValidation = false; } @@ -977,18 +988,18 @@ abstract class BaseFeature extends BaseObject implements Persistent $keys[4] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collFeatureAvs) { - $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureCategorys) { - $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collFeatureDescs) { $result['FeatureDescs'] = $this->collFeatureDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collFeatureAvs) { + $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collFeatureProds) { $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collFeatureCategorys) { + $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1158,30 +1169,30 @@ abstract class BaseFeature extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getFeatureAvs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureAv($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureCategory($relObj->copy($deepCopy)); - } - } - foreach ($this->getFeatureDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addFeatureDesc($relObj->copy($deepCopy)); } } + foreach ($this->getFeatureAvs() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFeatureAv($relObj->copy($deepCopy)); + } + } + foreach ($this->getFeatureProds() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addFeatureProd($relObj->copy($deepCopy)); } } + foreach ($this->getFeatureCategorys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFeatureCategory($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1243,17 +1254,224 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('FeatureDesc' == $relationName) { + $this->initFeatureDescs(); + } if ('FeatureAv' == $relationName) { $this->initFeatureAvs(); } + if ('FeatureProd' == $relationName) { + $this->initFeatureProds(); + } if ('FeatureCategory' == $relationName) { $this->initFeatureCategorys(); } - if ('FeatureDesc' == $relationName) { - $this->initFeatureDescs(); + } + + /** + * Clears out the collFeatureDescs collection + * + * 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 + * @see addFeatureDescs() + */ + public function clearFeatureDescs() + { + $this->collFeatureDescs = null; // important to set this to null since that means it is uninitialized + $this->collFeatureDescsPartial = null; + } + + /** + * reset is the collFeatureDescs collection loaded partially + * + * @return void + */ + public function resetPartialFeatureDescs($v = true) + { + $this->collFeatureDescsPartial = $v; + } + + /** + * Initializes the collFeatureDescs collection. + * + * By default this just sets the collFeatureDescs collection to an empty array (like clearcollFeatureDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFeatureDescs($overrideExisting = true) + { + if (null !== $this->collFeatureDescs && !$overrideExisting) { + return; } - if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); + $this->collFeatureDescs = new PropelObjectCollection(); + $this->collFeatureDescs->setModel('FeatureDesc'); + } + + /** + * Gets an array of FeatureDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Feature is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|FeatureDesc[] List of FeatureDesc objects + * @throws PropelException + */ + public function getFeatureDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collFeatureDescsPartial && !$this->isNew(); + if (null === $this->collFeatureDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureDescs) { + // return empty collection + $this->initFeatureDescs(); + } else { + $collFeatureDescs = FeatureDescQuery::create(null, $criteria) + ->filterByFeature($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collFeatureDescsPartial && count($collFeatureDescs)) { + $this->initFeatureDescs(false); + + foreach($collFeatureDescs as $obj) { + if (false == $this->collFeatureDescs->contains($obj)) { + $this->collFeatureDescs->append($obj); + } + } + + $this->collFeatureDescsPartial = true; + } + + return $collFeatureDescs; + } + + if($partial && $this->collFeatureDescs) { + foreach($this->collFeatureDescs as $obj) { + if($obj->isNew()) { + $collFeatureDescs[] = $obj; + } + } + } + + $this->collFeatureDescs = $collFeatureDescs; + $this->collFeatureDescsPartial = false; + } + } + + return $this->collFeatureDescs; + } + + /** + * Sets a collection of FeatureDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $featureDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setFeatureDescs(PropelCollection $featureDescs, PropelPDO $con = null) + { + $this->featureDescsScheduledForDeletion = $this->getFeatureDescs(new Criteria(), $con)->diff($featureDescs); + + foreach ($this->featureDescsScheduledForDeletion as $featureDescRemoved) { + $featureDescRemoved->setFeature(null); + } + + $this->collFeatureDescs = null; + foreach ($featureDescs as $featureDesc) { + $this->addFeatureDesc($featureDesc); + } + + $this->collFeatureDescs = $featureDescs; + $this->collFeatureDescsPartial = false; + } + + /** + * Returns the number of related FeatureDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related FeatureDesc objects. + * @throws PropelException + */ + public function countFeatureDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collFeatureDescsPartial && !$this->isNew(); + if (null === $this->collFeatureDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getFeatureDescs()); + } + $query = FeatureDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFeature($this) + ->count($con); + } + } else { + return count($this->collFeatureDescs); + } + } + + /** + * Method called to associate a FeatureDesc object to this object + * through the FeatureDesc foreign key attribute. + * + * @param FeatureDesc $l FeatureDesc + * @return Feature The current object (for fluent API support) + */ + public function addFeatureDesc(FeatureDesc $l) + { + if ($this->collFeatureDescs === null) { + $this->initFeatureDescs(); + $this->collFeatureDescsPartial = true; + } + if (!$this->collFeatureDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddFeatureDesc($l); + } + + return $this; + } + + /** + * @param FeatureDesc $featureDesc The featureDesc object to add. + */ + protected function doAddFeatureDesc($featureDesc) + { + $this->collFeatureDescs[]= $featureDesc; + $featureDesc->setFeature($this); + } + + /** + * @param FeatureDesc $featureDesc The featureDesc object to remove. + */ + public function removeFeatureDesc($featureDesc) + { + if ($this->getFeatureDescs()->contains($featureDesc)) { + $this->collFeatureDescs->remove($this->collFeatureDescs->search($featureDesc)); + if (null === $this->featureDescsScheduledForDeletion) { + $this->featureDescsScheduledForDeletion = clone $this->collFeatureDescs; + $this->featureDescsScheduledForDeletion->clear(); + } + $this->featureDescsScheduledForDeletion[]= $featureDesc; + $featureDesc->setFeature(null); } } @@ -1464,6 +1682,263 @@ abstract class BaseFeature extends BaseObject implements Persistent } } + /** + * Clears out the collFeatureProds collection + * + * 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 + * @see addFeatureProds() + */ + public function clearFeatureProds() + { + $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized + $this->collFeatureProdsPartial = null; + } + + /** + * reset is the collFeatureProds collection loaded partially + * + * @return void + */ + public function resetPartialFeatureProds($v = true) + { + $this->collFeatureProdsPartial = $v; + } + + /** + * Initializes the collFeatureProds collection. + * + * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFeatureProds($overrideExisting = true) + { + if (null !== $this->collFeatureProds && !$overrideExisting) { + return; + } + $this->collFeatureProds = new PropelObjectCollection(); + $this->collFeatureProds->setModel('FeatureProd'); + } + + /** + * Gets an array of FeatureProd objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Feature is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + * @throws PropelException + */ + public function getFeatureProds($criteria = null, PropelPDO $con = null) + { + $partial = $this->collFeatureProdsPartial && !$this->isNew(); + if (null === $this->collFeatureProds || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureProds) { + // return empty collection + $this->initFeatureProds(); + } else { + $collFeatureProds = FeatureProdQuery::create(null, $criteria) + ->filterByFeature($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { + $this->initFeatureProds(false); + + foreach($collFeatureProds as $obj) { + if (false == $this->collFeatureProds->contains($obj)) { + $this->collFeatureProds->append($obj); + } + } + + $this->collFeatureProdsPartial = true; + } + + return $collFeatureProds; + } + + if($partial && $this->collFeatureProds) { + foreach($this->collFeatureProds as $obj) { + if($obj->isNew()) { + $collFeatureProds[] = $obj; + } + } + } + + $this->collFeatureProds = $collFeatureProds; + $this->collFeatureProdsPartial = false; + } + } + + return $this->collFeatureProds; + } + + /** + * Sets a collection of FeatureProd objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $featureProds A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) + { + $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); + + foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { + $featureProdRemoved->setFeature(null); + } + + $this->collFeatureProds = null; + foreach ($featureProds as $featureProd) { + $this->addFeatureProd($featureProd); + } + + $this->collFeatureProds = $featureProds; + $this->collFeatureProdsPartial = false; + } + + /** + * Returns the number of related FeatureProd objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related FeatureProd objects. + * @throws PropelException + */ + public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collFeatureProdsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a FeatureProd object to this object + * through the FeatureProd foreign key attribute. + * + * @param FeatureProd $l FeatureProd + * @return Feature The current object (for fluent API support) + */ + public function addFeatureProd(FeatureProd $l) + { + if ($this->collFeatureProds === null) { + $this->initFeatureProds(); + $this->collFeatureProdsPartial = true; + } + if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddFeatureProd($l); + } + + return $this; + } + + /** + * @param FeatureProd $featureProd The featureProd object to add. + */ + protected function doAddFeatureProd($featureProd) + { + $this->collFeatureProds[]= $featureProd; + $featureProd->setFeature($this); + } + + /** + * @param FeatureProd $featureProd The featureProd object to remove. + */ + public function removeFeatureProd($featureProd) + { + if ($this->getFeatureProds()->contains($featureProd)) { + $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); + if (null === $this->featureProdsScheduledForDeletion) { + $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; + $this->featureProdsScheduledForDeletion->clear(); + } + $this->featureProdsScheduledForDeletion[]= $featureProd; + $featureProd->setFeature(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Feature is new, it will return + * an empty collection; or if this Feature has previously + * been saved, it will retrieve related FeatureProds from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Feature. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + */ + public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = FeatureProdQuery::create(null, $criteria); + $query->joinWith('Product', $join_behavior); + + return $this->getFeatureProds($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Feature is new, it will return + * an empty collection; or if this Feature has previously + * been saved, it will retrieve related FeatureProds from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Feature. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + */ + public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = FeatureProdQuery::create(null, $criteria); + $query->joinWith('FeatureAv', $join_behavior); + + return $this->getFeatureProds($query, $con); + } + /** * Clears out the collFeatureCategorys collection * @@ -1696,470 +2171,6 @@ abstract class BaseFeature extends BaseObject implements Persistent return $this->getFeatureCategorys($query, $con); } - /** - * Clears out the collFeatureDescs collection - * - * 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 - * @see addFeatureDescs() - */ - public function clearFeatureDescs() - { - $this->collFeatureDescs = null; // important to set this to null since that means it is uninitialized - $this->collFeatureDescsPartial = null; - } - - /** - * reset is the collFeatureDescs collection loaded partially - * - * @return void - */ - public function resetPartialFeatureDescs($v = true) - { - $this->collFeatureDescsPartial = $v; - } - - /** - * Initializes the collFeatureDescs collection. - * - * By default this just sets the collFeatureDescs collection to an empty array (like clearcollFeatureDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureDescs($overrideExisting = true) - { - if (null !== $this->collFeatureDescs && !$overrideExisting) { - return; - } - $this->collFeatureDescs = new PropelObjectCollection(); - $this->collFeatureDescs->setModel('FeatureDesc'); - } - - /** - * Gets an array of FeatureDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureDesc[] List of FeatureDesc objects - * @throws PropelException - */ - public function getFeatureDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureDescsPartial && !$this->isNew(); - if (null === $this->collFeatureDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureDescs) { - // return empty collection - $this->initFeatureDescs(); - } else { - $collFeatureDescs = FeatureDescQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureDescsPartial && count($collFeatureDescs)) { - $this->initFeatureDescs(false); - - foreach($collFeatureDescs as $obj) { - if (false == $this->collFeatureDescs->contains($obj)) { - $this->collFeatureDescs->append($obj); - } - } - - $this->collFeatureDescsPartial = true; - } - - return $collFeatureDescs; - } - - if($partial && $this->collFeatureDescs) { - foreach($this->collFeatureDescs as $obj) { - if($obj->isNew()) { - $collFeatureDescs[] = $obj; - } - } - } - - $this->collFeatureDescs = $collFeatureDescs; - $this->collFeatureDescsPartial = false; - } - } - - return $this->collFeatureDescs; - } - - /** - * Sets a collection of FeatureDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setFeatureDescs(PropelCollection $featureDescs, PropelPDO $con = null) - { - $this->featureDescsScheduledForDeletion = $this->getFeatureDescs(new Criteria(), $con)->diff($featureDescs); - - foreach ($this->featureDescsScheduledForDeletion as $featureDescRemoved) { - $featureDescRemoved->setFeature(null); - } - - $this->collFeatureDescs = null; - foreach ($featureDescs as $featureDesc) { - $this->addFeatureDesc($featureDesc); - } - - $this->collFeatureDescs = $featureDescs; - $this->collFeatureDescsPartial = false; - } - - /** - * Returns the number of related FeatureDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureDesc objects. - * @throws PropelException - */ - public function countFeatureDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureDescsPartial && !$this->isNew(); - if (null === $this->collFeatureDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getFeatureDescs()); - } - $query = FeatureDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - } else { - return count($this->collFeatureDescs); - } - } - - /** - * Method called to associate a FeatureDesc object to this object - * through the FeatureDesc foreign key attribute. - * - * @param FeatureDesc $l FeatureDesc - * @return Feature The current object (for fluent API support) - */ - public function addFeatureDesc(FeatureDesc $l) - { - if ($this->collFeatureDescs === null) { - $this->initFeatureDescs(); - $this->collFeatureDescsPartial = true; - } - if (!$this->collFeatureDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddFeatureDesc($l); - } - - return $this; - } - - /** - * @param FeatureDesc $featureDesc The featureDesc object to add. - */ - protected function doAddFeatureDesc($featureDesc) - { - $this->collFeatureDescs[]= $featureDesc; - $featureDesc->setFeature($this); - } - - /** - * @param FeatureDesc $featureDesc The featureDesc object to remove. - */ - public function removeFeatureDesc($featureDesc) - { - if ($this->getFeatureDescs()->contains($featureDesc)) { - $this->collFeatureDescs->remove($this->collFeatureDescs->search($featureDesc)); - if (null === $this->featureDescsScheduledForDeletion) { - $this->featureDescsScheduledForDeletion = clone $this->collFeatureDescs; - $this->featureDescsScheduledForDeletion->clear(); - } - $this->featureDescsScheduledForDeletion[]= $featureDesc; - $featureDesc->setFeature(null); - } - } - - /** - * Clears out the collFeatureProds collection - * - * 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 - * @see addFeatureProds() - */ - public function clearFeatureProds() - { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - } - - /** - * reset is the collFeatureProds collection loaded partially - * - * @return void - */ - public function resetPartialFeatureProds($v = true) - { - $this->collFeatureProdsPartial = $v; - } - - /** - * Initializes the collFeatureProds collection. - * - * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureProds($overrideExisting = true) - { - if (null !== $this->collFeatureProds && !$overrideExisting) { - return; - } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); - } - - /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - * @throws PropelException - */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - // return empty collection - $this->initFeatureProds(); - } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); - - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); - } - } - - $this->collFeatureProdsPartial = true; - } - - return $collFeatureProds; - } - - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { - $collFeatureProds[] = $obj; - } - } - } - - $this->collFeatureProds = $collFeatureProds; - $this->collFeatureProdsPartial = false; - } - } - - return $this->collFeatureProds; - } - - /** - * Sets a collection of FeatureProd objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureProds A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) - { - $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - - foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { - $featureProdRemoved->setFeature(null); - } - - $this->collFeatureProds = null; - foreach ($featureProds as $featureProd) { - $this->addFeatureProd($featureProd); - } - - $this->collFeatureProds = $featureProds; - $this->collFeatureProdsPartial = false; - } - - /** - * Returns the number of related FeatureProd objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureProd objects. - * @throws PropelException - */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. - * - * @param FeatureProd $l FeatureProd - * @return Feature The current object (for fluent API support) - */ - public function addFeatureProd(FeatureProd $l) - { - if ($this->collFeatureProds === null) { - $this->initFeatureProds(); - $this->collFeatureProdsPartial = true; - } - if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddFeatureProd($l); - } - - return $this; - } - - /** - * @param FeatureProd $featureProd The featureProd object to add. - */ - protected function doAddFeatureProd($featureProd) - { - $this->collFeatureProds[]= $featureProd; - $featureProd->setFeature($this); - } - - /** - * @param FeatureProd $featureProd The featureProd object to remove. - */ - public function removeFeatureProd($featureProd) - { - if ($this->getFeatureProds()->contains($featureProd)) { - $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); - if (null === $this->featureProdsScheduledForDeletion) { - $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; - $this->featureProdsScheduledForDeletion->clear(); - } - $this->featureProdsScheduledForDeletion[]= $featureProd; - $featureProd->setFeature(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Feature is new, it will return - * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Feature. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Feature is new, it will return - * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Feature. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - /** * Clears the current object and sets all attributes to their default values */ @@ -2191,44 +2202,44 @@ abstract class BaseFeature extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collFeatureAvs) { - foreach ($this->collFeatureAvs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureCategorys) { - foreach ($this->collFeatureCategorys as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collFeatureDescs) { foreach ($this->collFeatureDescs as $o) { $o->clearAllReferences($deep); } } + if ($this->collFeatureAvs) { + foreach ($this->collFeatureAvs as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collFeatureProds) { foreach ($this->collFeatureProds as $o) { $o->clearAllReferences($deep); } } + if ($this->collFeatureCategorys) { + foreach ($this->collFeatureCategorys as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collFeatureAvs instanceof PropelCollection) { - $this->collFeatureAvs->clearIterator(); - } - $this->collFeatureAvs = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); - } - $this->collFeatureCategorys = null; if ($this->collFeatureDescs instanceof PropelCollection) { $this->collFeatureDescs->clearIterator(); } $this->collFeatureDescs = null; + if ($this->collFeatureAvs instanceof PropelCollection) { + $this->collFeatureAvs->clearIterator(); + } + $this->collFeatureAvs = null; if ($this->collFeatureProds instanceof PropelCollection) { $this->collFeatureProds->clearIterator(); } $this->collFeatureProds = null; + if ($this->collFeatureCategorys instanceof PropelCollection) { + $this->collFeatureCategorys->clearIterator(); + } + $this->collFeatureCategorys = null; } /** @@ -2251,4 +2262,18 @@ abstract class BaseFeature extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Feature The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeaturePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/om/BaseFeatureAv.php index 1b8704563..933dd398d 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAv.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAv.php @@ -492,8 +492,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureAvPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1596,10 +1607,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); + $query->joinWith('Product', $join_behavior); return $this->getFeatureProds($query, $con); } @@ -1621,10 +1632,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query->joinWith('Feature', $join_behavior); return $this->getFeatureProds($query, $con); } @@ -1701,4 +1712,18 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FeatureAv The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php index d01569462..ae82494f8 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvDesc.php @@ -5,10 +5,12 @@ namespace Thelia\Model\om; use \BaseObject; use \BasePeer; use \Criteria; +use \DateTime; use \Exception; use \PDO; use \Persistent; use \Propel; +use \PropelDateTime; use \PropelException; use \PropelPDO; use Thelia\Model\FeatureAv; @@ -81,6 +83,18 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent */ protected $chapo; + /** + * The value for the created_at field. + * @var string + */ + protected $created_at; + + /** + * The value for the updated_at field. + * @var string + */ + protected $updated_at; + /** * @var FeatureAv */ @@ -160,6 +174,80 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent return $this->chapo; } + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + if ($this->created_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + if ($this->updated_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + /** * Set the value of [id] column. * @@ -290,6 +378,52 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent return $this; } // setChapo() + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return FeatureAvDesc The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = FeatureAvDescPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return FeatureAvDesc The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = FeatureAvDescPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + /** * Indicates whether the columns in this object are only set to default values. * @@ -328,6 +462,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->resetModified(); $this->setNew(false); @@ -336,7 +472,7 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 6; // 6 = FeatureAvDescPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = FeatureAvDescPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating FeatureAvDesc object", $e); @@ -474,8 +610,19 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureAvDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureAvDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureAvDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -582,6 +729,12 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent if ($this->isColumnModified(FeatureAvDescPeer::CHAPO)) { $modifiedColumns[':p' . $index++] = '`CHAPO`'; } + if ($this->isColumnModified(FeatureAvDescPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + } + if ($this->isColumnModified(FeatureAvDescPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + } $sql = sprintf( 'INSERT INTO `feature_av_desc` (%s) VALUES (%s)', @@ -611,6 +764,12 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent case '`CHAPO`': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; + case '`CREATED_AT`': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '`UPDATED_AT`': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -775,6 +934,12 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent case 5: return $this->getChapo(); break; + case 6: + return $this->getCreatedAt(); + break; + case 7: + return $this->getUpdatedAt(); + break; default: return null; break; @@ -810,6 +975,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $keys[3] => $this->getTitle(), $keys[4] => $this->getDescription(), $keys[5] => $this->getChapo(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { if (null !== $this->aFeatureAv) { @@ -867,6 +1034,12 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent case 5: $this->setChapo($value); break; + case 6: + $this->setCreatedAt($value); + break; + case 7: + $this->setUpdatedAt($value); + break; } // switch() } @@ -897,6 +1070,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); } /** @@ -914,6 +1089,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent if ($this->isColumnModified(FeatureAvDescPeer::TITLE)) $criteria->add(FeatureAvDescPeer::TITLE, $this->title); if ($this->isColumnModified(FeatureAvDescPeer::DESCRIPTION)) $criteria->add(FeatureAvDescPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(FeatureAvDescPeer::CHAPO)) $criteria->add(FeatureAvDescPeer::CHAPO, $this->chapo); + if ($this->isColumnModified(FeatureAvDescPeer::CREATED_AT)) $criteria->add(FeatureAvDescPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureAvDescPeer::UPDATED_AT)) $criteria->add(FeatureAvDescPeer::UPDATED_AT, $this->updated_at); return $criteria; } @@ -982,6 +1159,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $copyObj->setTitle($this->getTitle()); $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1102,6 +1281,8 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent $this->title = null; $this->description = null; $this->chapo = null; + $this->created_at = null; + $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); @@ -1147,4 +1328,18 @@ abstract class BaseFeatureAvDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FeatureAvDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureAvDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php index 6799cdd18..629e08ec9 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescPeer.php @@ -37,13 +37,13 @@ abstract class BaseFeatureAvDescPeer const TM_CLASS = 'FeatureAvDescTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 6; + const NUM_COLUMNS = 8; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 6; + const NUM_HYDRATE_COLUMNS = 8; /** the column name for the ID field */ const ID = 'feature_av_desc.ID'; @@ -63,6 +63,12 @@ abstract class BaseFeatureAvDescPeer /** the column name for the CHAPO field */ const CHAPO = 'feature_av_desc.CHAPO'; + /** the column name for the CREATED_AT field */ + const CREATED_AT = 'feature_av_desc.CREATED_AT'; + + /** the column name for the UPDATED_AT field */ + const UPDATED_AT = 'feature_av_desc.UPDATED_AT'; + /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -82,12 +88,12 @@ abstract class BaseFeatureAvDescPeer * e.g. FeatureAvDescPeer::$fieldNames[FeatureAvDescPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'FeatureAvId', 'Lang', 'Title', 'Description', 'Chapo', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureAvId', 'lang', 'title', 'description', 'chapo', ), - BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvDescPeer::LANG, FeatureAvDescPeer::TITLE, FeatureAvDescPeer::DESCRIPTION, FeatureAvDescPeer::CHAPO, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_AV_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'feature_av_id', 'lang', 'title', 'description', 'chapo', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('Id', 'FeatureAvId', 'Lang', 'Title', 'Description', 'Chapo', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureAvId', 'lang', 'title', 'description', 'chapo', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID, FeatureAvDescPeer::FEATURE_AV_ID, FeatureAvDescPeer::LANG, FeatureAvDescPeer::TITLE, FeatureAvDescPeer::DESCRIPTION, FeatureAvDescPeer::CHAPO, FeatureAvDescPeer::CREATED_AT, FeatureAvDescPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_AV_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'feature_av_id', 'lang', 'title', 'description', 'chapo', 'created_at', 'updated_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -97,12 +103,12 @@ abstract class BaseFeatureAvDescPeer * e.g. FeatureAvDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureAvId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureAvId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, ), - BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID => 0, FeatureAvDescPeer::FEATURE_AV_ID => 1, FeatureAvDescPeer::LANG => 2, FeatureAvDescPeer::TITLE => 3, FeatureAvDescPeer::DESCRIPTION => 4, FeatureAvDescPeer::CHAPO => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_AV_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_av_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureAvId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureAvId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + BasePeer::TYPE_COLNAME => array (FeatureAvDescPeer::ID => 0, FeatureAvDescPeer::FEATURE_AV_ID => 1, FeatureAvDescPeer::LANG => 2, FeatureAvDescPeer::TITLE => 3, FeatureAvDescPeer::DESCRIPTION => 4, FeatureAvDescPeer::CHAPO => 5, FeatureAvDescPeer::CREATED_AT => 6, FeatureAvDescPeer::UPDATED_AT => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_AV_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_av_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'created_at' => 6, 'updated_at' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -182,6 +188,8 @@ abstract class BaseFeatureAvDescPeer $criteria->addSelectColumn(FeatureAvDescPeer::TITLE); $criteria->addSelectColumn(FeatureAvDescPeer::DESCRIPTION); $criteria->addSelectColumn(FeatureAvDescPeer::CHAPO); + $criteria->addSelectColumn(FeatureAvDescPeer::CREATED_AT); + $criteria->addSelectColumn(FeatureAvDescPeer::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.FEATURE_AV_ID'); @@ -189,6 +197,8 @@ abstract class BaseFeatureAvDescPeer $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); } } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php index 001058925..dca3a0e9f 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvDescQuery.php @@ -28,6 +28,8 @@ use Thelia\Model\FeatureAvDescQuery; * @method FeatureAvDescQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method FeatureAvDescQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method FeatureAvDescQuery orderByChapo($order = Criteria::ASC) Order by the chapo column + * @method FeatureAvDescQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method FeatureAvDescQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method FeatureAvDescQuery groupById() Group by the id column * @method FeatureAvDescQuery groupByFeatureAvId() Group by the feature_av_id column @@ -35,6 +37,8 @@ use Thelia\Model\FeatureAvDescQuery; * @method FeatureAvDescQuery groupByTitle() Group by the title column * @method FeatureAvDescQuery groupByDescription() Group by the description column * @method FeatureAvDescQuery groupByChapo() Group by the chapo column + * @method FeatureAvDescQuery groupByCreatedAt() Group by the created_at column + * @method FeatureAvDescQuery groupByUpdatedAt() Group by the updated_at column * * @method FeatureAvDescQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method FeatureAvDescQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -53,6 +57,8 @@ use Thelia\Model\FeatureAvDescQuery; * @method FeatureAvDesc findOneByTitle(string $title) Return the first FeatureAvDesc filtered by the title column * @method FeatureAvDesc findOneByDescription(string $description) Return the first FeatureAvDesc filtered by the description column * @method FeatureAvDesc findOneByChapo(string $chapo) Return the first FeatureAvDesc filtered by the chapo column + * @method FeatureAvDesc findOneByCreatedAt(string $created_at) Return the first FeatureAvDesc filtered by the created_at column + * @method FeatureAvDesc findOneByUpdatedAt(string $updated_at) Return the first FeatureAvDesc filtered by the updated_at column * * @method array findById(int $id) Return FeatureAvDesc objects filtered by the id column * @method array findByFeatureAvId(int $feature_av_id) Return FeatureAvDesc objects filtered by the feature_av_id column @@ -60,6 +66,8 @@ use Thelia\Model\FeatureAvDescQuery; * @method array findByTitle(string $title) Return FeatureAvDesc objects filtered by the title column * @method array findByDescription(string $description) Return FeatureAvDesc objects filtered by the description column * @method array findByChapo(string $chapo) Return FeatureAvDesc objects filtered by the chapo column + * @method array findByCreatedAt(string $created_at) Return FeatureAvDesc objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return FeatureAvDesc objects filtered by the updated_at column * * @package propel.generator.Thelia.Model.om */ @@ -149,7 +157,7 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `FEATURE_AV_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO` FROM `feature_av_desc` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `FEATURE_AV_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `CREATED_AT`, `UPDATED_AT` FROM `feature_av_desc` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -424,6 +432,92 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria return $this->addUsingAlias(FeatureAvDescPeer::CHAPO, $chapo, $comparison); } + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(FeatureAvDescPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(FeatureAvDescPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FeatureAvDescPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(FeatureAvDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(FeatureAvDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FeatureAvDescPeer::UPDATED_AT, $updatedAt, $comparison); + } + /** * Filter the query by a related FeatureAv object * @@ -516,4 +610,69 @@ abstract class BaseFeatureAvDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeatureAvDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureAvDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureAvDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeatureAvDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureAvDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureAvDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureAvDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php index 56948a5d2..b1f962a02 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php @@ -636,4 +636,69 @@ abstract class BaseFeatureAvQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureAvPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureAvPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeatureAvPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureAvPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureAvQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureAvPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategory.php b/core/lib/Thelia/Model/om/BaseFeatureCategory.php index 098fe90cb..351438774 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureCategory.php +++ b/core/lib/Thelia/Model/om/BaseFeatureCategory.php @@ -511,8 +511,19 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1235,4 +1246,18 @@ abstract class BaseFeatureCategory extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FeatureCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureCategoryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php index 262bd682a..cfb16be58 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php @@ -606,4 +606,69 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureCategoryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureCategoryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureCategoryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeatureDesc.php b/core/lib/Thelia/Model/om/BaseFeatureDesc.php index f33be3c8f..9581d2214 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureDesc.php +++ b/core/lib/Thelia/Model/om/BaseFeatureDesc.php @@ -610,8 +610,19 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseFeatureDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FeatureDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php index bf5bc3372..9d1f956b8 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseFeatureDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeatureDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeatureDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeaturePeer.php b/core/lib/Thelia/Model/om/BaseFeaturePeer.php index b5d43299c..a12e4c26b 100644 --- a/core/lib/Thelia/Model/om/BaseFeaturePeer.php +++ b/core/lib/Thelia/Model/om/BaseFeaturePeer.php @@ -386,18 +386,18 @@ abstract class BaseFeaturePeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in FeatureAvPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureAvPeer::clearInstancePool(); - // Invalidate objects in FeatureCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureCategoryPeer::clearInstancePool(); // Invalidate objects in FeatureDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. FeatureDescPeer::clearInstancePool(); + // Invalidate objects in FeatureAvPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureAvPeer::clearInstancePool(); // Invalidate objects in FeatureProdPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. FeatureProdPeer::clearInstancePool(); + // Invalidate objects in FeatureCategoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureCategoryPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/om/BaseFeatureProd.php index b38cf038a..62e2fcd4d 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProd.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProd.php @@ -76,10 +76,10 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent protected $feature_av_id; /** - * The value for the default_utility field. + * The value for the by_default field. * @var string */ - protected $default_utility; + protected $by_default; /** * The value for the position field. @@ -100,9 +100,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent protected $updated_at; /** - * @var FeatureAv + * @var Product */ - protected $aFeatureAv; + protected $aProduct; /** * @var Feature @@ -110,9 +110,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent protected $aFeature; /** - * @var Product + * @var FeatureAv */ - protected $aProduct; + protected $aFeatureAv; /** * Flag to prevent endless save loop, if this object is referenced @@ -169,13 +169,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Get the [default_utility] column value. + * Get the [by_default] column value. * * @return string */ - public function getDefaultUtility() + public function getByDefault() { - return $this->default_utility; + return $this->by_default; } /** @@ -359,25 +359,25 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } // setFeatureAvId() /** - * Set the value of [default_utility] column. + * Set the value of [by_default] column. * * @param string $v new value * @return FeatureProd The current object (for fluent API support) */ - public function setDefaultUtility($v) + public function setByDefault($v) { if ($v !== null) { $v = (string) $v; } - if ($this->default_utility !== $v) { - $this->default_utility = $v; - $this->modifiedColumns[] = FeatureProdPeer::DEFAULT_UTILITY; + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = FeatureProdPeer::BY_DEFAULT; } return $this; - } // setDefaultUtility() + } // setByDefault() /** * Set the value of [position] column. @@ -482,7 +482,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; $this->feature_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->feature_av_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->default_utility = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->by_default = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->position = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; @@ -565,9 +565,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->aFeatureAv = null; - $this->aFeature = null; $this->aProduct = null; + $this->aFeature = null; + $this->aFeatureAv = null; } // if (deep) } @@ -640,8 +640,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureProdPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -686,11 +697,11 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aFeatureAv !== null) { - if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) { - $affectedRows += $this->aFeatureAv->save($con); + if ($this->aProduct !== null) { + if ($this->aProduct->isModified() || $this->aProduct->isNew()) { + $affectedRows += $this->aProduct->save($con); } - $this->setFeatureAv($this->aFeatureAv); + $this->setProduct($this->aProduct); } if ($this->aFeature !== null) { @@ -700,11 +711,11 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->setFeature($this->aFeature); } - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); + if ($this->aFeatureAv !== null) { + if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) { + $affectedRows += $this->aFeatureAv->save($con); } - $this->setProduct($this->aProduct); + $this->setFeatureAv($this->aFeatureAv); } if ($this->isNew() || $this->isModified()) { @@ -756,8 +767,8 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) { $modifiedColumns[':p' . $index++] = '`FEATURE_AV_ID`'; } - if ($this->isColumnModified(FeatureProdPeer::DEFAULT_UTILITY)) { - $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`'; + if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; } if ($this->isColumnModified(FeatureProdPeer::POSITION)) { $modifiedColumns[':p' . $index++] = '`POSITION`'; @@ -791,8 +802,8 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent case '`FEATURE_AV_ID`': $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); break; - case '`DEFAULT_UTILITY`': - $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_STR); + case '`BY_DEFAULT`': + $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); break; case '`POSITION`': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); @@ -902,9 +913,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aFeatureAv !== null) { - if (!$this->aFeatureAv->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeatureAv->getValidationFailures()); + if ($this->aProduct !== null) { + if (!$this->aProduct->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); } } @@ -914,9 +925,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } } - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); + if ($this->aFeatureAv !== null) { + if (!$this->aFeatureAv->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aFeatureAv->getValidationFailures()); } } @@ -974,7 +985,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent return $this->getFeatureAvId(); break; case 4: - return $this->getDefaultUtility(); + return $this->getByDefault(); break; case 5: return $this->getPosition(); @@ -1018,20 +1029,20 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $keys[1] => $this->getProductId(), $keys[2] => $this->getFeatureId(), $keys[3] => $this->getFeatureAvId(), - $keys[4] => $this->getDefaultUtility(), + $keys[4] => $this->getByDefault(), $keys[5] => $this->getPosition(), $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->aFeatureAv) { - $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aProduct) { + $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aFeature) { $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aFeatureAv) { + $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1080,7 +1091,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->setFeatureAvId($value); break; case 4: - $this->setDefaultUtility($value); + $this->setByDefault($value); break; case 5: $this->setPosition($value); @@ -1119,7 +1130,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDefaultUtility($arr[$keys[4]]); + if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); @@ -1138,7 +1149,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) $criteria->add(FeatureProdPeer::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) $criteria->add(FeatureProdPeer::FEATURE_ID, $this->feature_id); if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) $criteria->add(FeatureProdPeer::FEATURE_AV_ID, $this->feature_av_id); - if ($this->isColumnModified(FeatureProdPeer::DEFAULT_UTILITY)) $criteria->add(FeatureProdPeer::DEFAULT_UTILITY, $this->default_utility); + if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) $criteria->add(FeatureProdPeer::BY_DEFAULT, $this->by_default); if ($this->isColumnModified(FeatureProdPeer::POSITION)) $criteria->add(FeatureProdPeer::POSITION, $this->position); if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) $criteria->add(FeatureProdPeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) $criteria->add(FeatureProdPeer::UPDATED_AT, $this->updated_at); @@ -1208,7 +1219,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $copyObj->setProductId($this->getProductId()); $copyObj->setFeatureId($this->getFeatureId()); $copyObj->setFeatureAvId($this->getFeatureAvId()); - $copyObj->setDefaultUtility($this->getDefaultUtility()); + $copyObj->setByDefault($this->getByDefault()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1271,24 +1282,24 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Declares an association between this object and a FeatureAv object. + * Declares an association between this object and a Product object. * - * @param FeatureAv $v + * @param Product $v * @return FeatureProd The current object (for fluent API support) * @throws PropelException */ - public function setFeatureAv(FeatureAv $v = null) + public function setProduct(Product $v = null) { if ($v === null) { - $this->setFeatureAvId(NULL); + $this->setProductId(NULL); } else { - $this->setFeatureAvId($v->getId()); + $this->setProductId($v->getId()); } - $this->aFeatureAv = $v; + $this->aProduct = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the FeatureAv object, it will not be re-added. + // If this object has already been added to the Product object, it will not be re-added. if ($v !== null) { $v->addFeatureProd($this); } @@ -1299,26 +1310,26 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** - * Get the associated FeatureAv object + * Get the associated Product object * * @param PropelPDO $con Optional Connection object. - * @return FeatureAv The associated FeatureAv object. + * @return Product The associated Product object. * @throws PropelException */ - public function getFeatureAv(PropelPDO $con = null) + public function getProduct(PropelPDO $con = null) { - if ($this->aFeatureAv === null && ($this->feature_av_id !== null)) { - $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->feature_av_id, $con); + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aFeatureAv->addFeatureProds($this); + $this->aProduct->addFeatureProds($this); */ } - return $this->aFeatureAv; + return $this->aProduct; } /** @@ -1373,24 +1384,24 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Declares an association between this object and a Product object. + * Declares an association between this object and a FeatureAv object. * - * @param Product $v + * @param FeatureAv $v * @return FeatureProd The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setFeatureAv(FeatureAv $v = null) { if ($v === null) { - $this->setProductId(NULL); + $this->setFeatureAvId(NULL); } else { - $this->setProductId($v->getId()); + $this->setFeatureAvId($v->getId()); } - $this->aProduct = $v; + $this->aFeatureAv = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. + // If this object has already been added to the FeatureAv object, it will not be re-added. if ($v !== null) { $v->addFeatureProd($this); } @@ -1401,26 +1412,26 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated FeatureAv object * * @param PropelPDO $con Optional Connection object. - * @return Product The associated Product object. + * @return FeatureAv The associated FeatureAv object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null) + public function getFeatureAv(PropelPDO $con = null) { - if ($this->aProduct === null && ($this->product_id !== null)) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); + if ($this->aFeatureAv === null && ($this->feature_av_id !== null)) { + $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->feature_av_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aProduct->addFeatureProds($this); + $this->aFeatureAv->addFeatureProds($this); */ } - return $this->aProduct; + return $this->aFeatureAv; } /** @@ -1432,7 +1443,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->product_id = null; $this->feature_id = null; $this->feature_av_id = null; - $this->default_utility = null; + $this->by_default = null; $this->position = null; $this->created_at = null; $this->updated_at = null; @@ -1458,9 +1469,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($deep) { } // if ($deep) - $this->aFeatureAv = null; - $this->aFeature = null; $this->aProduct = null; + $this->aFeature = null; + $this->aFeatureAv = null; } /** @@ -1483,4 +1494,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FeatureProd The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureProdPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php index 235e9cefa..d17925d3b 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php @@ -59,8 +59,8 @@ abstract class BaseFeatureProdPeer /** the column name for the FEATURE_AV_ID field */ const FEATURE_AV_ID = 'feature_prod.FEATURE_AV_ID'; - /** the column name for the DEFAULT_UTILITY field */ - const DEFAULT_UTILITY = 'feature_prod.DEFAULT_UTILITY'; + /** 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'; @@ -90,11 +90,11 @@ abstract class BaseFeatureProdPeer * e.g. FeatureProdPeer::$fieldNames[FeatureProdPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'DefaultUtility', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'featureId', 'featureAvId', 'defaultUtility', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID, FeatureProdPeer::PRODUCT_ID, FeatureProdPeer::FEATURE_ID, FeatureProdPeer::FEATURE_AV_ID, FeatureProdPeer::DEFAULT_UTILITY, FeatureProdPeer::POSITION, FeatureProdPeer::CREATED_AT, FeatureProdPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'DEFAULT_UTILITY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'feature_id', 'feature_av_id', 'default_utility', 'position', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID, FeatureProdPeer::PRODUCT_ID, FeatureProdPeer::FEATURE_ID, FeatureProdPeer::FEATURE_AV_ID, FeatureProdPeer::BY_DEFAULT, FeatureProdPeer::POSITION, FeatureProdPeer::CREATED_AT, FeatureProdPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -105,11 +105,11 @@ abstract class BaseFeatureProdPeer * e.g. FeatureProdPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'DefaultUtility' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'defaultUtility' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID => 0, FeatureProdPeer::PRODUCT_ID => 1, FeatureProdPeer::FEATURE_ID => 2, FeatureProdPeer::FEATURE_AV_ID => 3, FeatureProdPeer::DEFAULT_UTILITY => 4, FeatureProdPeer::POSITION => 5, FeatureProdPeer::CREATED_AT => 6, FeatureProdPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'DEFAULT_UTILITY' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'default_utility' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID => 0, FeatureProdPeer::PRODUCT_ID => 1, FeatureProdPeer::FEATURE_ID => 2, FeatureProdPeer::FEATURE_AV_ID => 3, FeatureProdPeer::BY_DEFAULT => 4, FeatureProdPeer::POSITION => 5, FeatureProdPeer::CREATED_AT => 6, FeatureProdPeer::UPDATED_AT => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -188,7 +188,7 @@ abstract class BaseFeatureProdPeer $criteria->addSelectColumn(FeatureProdPeer::PRODUCT_ID); $criteria->addSelectColumn(FeatureProdPeer::FEATURE_ID); $criteria->addSelectColumn(FeatureProdPeer::FEATURE_AV_ID); - $criteria->addSelectColumn(FeatureProdPeer::DEFAULT_UTILITY); + $criteria->addSelectColumn(FeatureProdPeer::BY_DEFAULT); $criteria->addSelectColumn(FeatureProdPeer::POSITION); $criteria->addSelectColumn(FeatureProdPeer::CREATED_AT); $criteria->addSelectColumn(FeatureProdPeer::UPDATED_AT); @@ -197,7 +197,7 @@ abstract class BaseFeatureProdPeer $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); $criteria->addSelectColumn($alias . '.FEATURE_AV_ID'); - $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY'); + $criteria->addSelectColumn($alias . '.BY_DEFAULT'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); @@ -498,7 +498,7 @@ abstract class BaseFeatureProdPeer /** - * Returns the number of rows matching criteria, joining the related FeatureAv table + * Returns the number of rows matching criteria, joining the related Product table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -506,7 +506,7 @@ abstract class BaseFeatureProdPeer * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ - public static function doCountJoinFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; @@ -533,7 +533,7 @@ abstract class BaseFeatureProdPeer $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); } - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); @@ -600,7 +600,7 @@ abstract class BaseFeatureProdPeer /** - * Returns the number of rows matching criteria, joining the related Product table + * Returns the number of rows matching criteria, joining the related FeatureAv table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -608,7 +608,7 @@ abstract class BaseFeatureProdPeer * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doCountJoinFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; @@ -635,7 +635,7 @@ abstract class BaseFeatureProdPeer $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); } - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); @@ -651,7 +651,7 @@ abstract class BaseFeatureProdPeer /** - * Selects a collection of FeatureProd objects pre-filled with their FeatureAv objects. + * Selects a collection of FeatureProd objects pre-filled with their Product objects. * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN @@ -659,7 +659,7 @@ abstract class BaseFeatureProdPeer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoinFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; @@ -670,9 +670,9 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addSelectColumns($criteria); $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); + ProductPeer::addSelectColumns($criteria); - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); @@ -692,19 +692,19 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addInstanceToPool($obj1, $key1); } // if $obj1 already loaded - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol); + $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); + $obj2 = ProductPeer::getInstanceFromPool($key2); if (!$obj2) { - $cls = FeatureAvPeer::getOMClass(); + $cls = ProductPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol); - FeatureAvPeer::addInstanceToPool($obj2, $key2); + ProductPeer::addInstanceToPool($obj2, $key2); } // if obj2 already loaded - // Add the $obj1 (FeatureProd) to $obj2 (FeatureAv) + // Add the $obj1 (FeatureProd) to $obj2 (Product) $obj2->addFeatureProd($obj1); } // if joined row was not null @@ -785,7 +785,7 @@ abstract class BaseFeatureProdPeer /** - * Selects a collection of FeatureProd objects pre-filled with their Product objects. + * Selects a collection of FeatureProd objects pre-filled with their FeatureAv objects. * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN @@ -793,7 +793,7 @@ abstract class BaseFeatureProdPeer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doSelectJoinFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; @@ -804,9 +804,9 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addSelectColumns($criteria); $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); + FeatureAvPeer::addSelectColumns($criteria); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); @@ -826,19 +826,19 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addInstanceToPool($obj1, $key1); } // if $obj1 already loaded - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); + $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol); if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); + $obj2 = FeatureAvPeer::getInstanceFromPool($key2); if (!$obj2) { - $cls = ProductPeer::getOMClass(); + $cls = FeatureAvPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); + FeatureAvPeer::addInstanceToPool($obj2, $key2); } // if obj2 already loaded - // Add the $obj1 (FeatureProd) to $obj2 (Product) + // Add the $obj1 (FeatureProd) to $obj2 (FeatureAv) $obj2->addFeatureProd($obj1); } // if joined row was not null @@ -887,11 +887,11 @@ abstract class BaseFeatureProdPeer $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); } - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); @@ -927,20 +927,20 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addSelectColumns($criteria); $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; + ProductPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; FeaturePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ProductPeer::NUM_HYDRATE_COLUMNS; + FeatureAvPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); @@ -959,21 +959,21 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded - // Add objects for joined FeatureAv rows + // Add objects for joined Product rows - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); + $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); + $obj2 = ProductPeer::getInstanceFromPool($key2); if (!$obj2) { - $cls = FeatureAvPeer::getOMClass(); + $cls = ProductPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); - FeatureAvPeer::addInstanceToPool($obj2, $key2); + ProductPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded - // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv) + // Add the $obj1 (FeatureProd) to the collection in $obj2 (Product) $obj2->addFeatureProd($obj1); } // if joined row not null @@ -995,21 +995,21 @@ abstract class BaseFeatureProdPeer $obj3->addFeatureProd($obj1); } // if joined row not null - // Add objects for joined Product rows + // Add objects for joined FeatureAv rows - $key4 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol4); + $key4 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { - $obj4 = ProductPeer::getInstanceFromPool($key4); + $obj4 = FeatureAvPeer::getInstanceFromPool($key4); if (!$obj4) { - $cls = ProductPeer::getOMClass(); + $cls = FeatureAvPeer::getOMClass(); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); - ProductPeer::addInstanceToPool($obj4, $key4); + FeatureAvPeer::addInstanceToPool($obj4, $key4); } // if obj4 loaded - // Add the $obj1 (FeatureProd) to the collection in $obj4 (Product) + // Add the $obj1 (FeatureProd) to the collection in $obj4 (FeatureAv) $obj4->addFeatureProd($obj1); } // if joined row not null @@ -1022,7 +1022,7 @@ abstract class BaseFeatureProdPeer /** - * Returns the number of rows matching criteria, joining the related FeatureAv table + * Returns the number of rows matching criteria, joining the related Product table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -1030,7 +1030,7 @@ abstract class BaseFeatureProdPeer * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ - public static function doCountJoinAllExceptFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; @@ -1059,7 +1059,7 @@ abstract class BaseFeatureProdPeer $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); @@ -1110,10 +1110,10 @@ abstract class BaseFeatureProdPeer $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); } - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { @@ -1128,7 +1128,7 @@ abstract class BaseFeatureProdPeer /** - * Returns the number of rows matching criteria, joining the related Product table + * Returns the number of rows matching criteria, joining the related FeatureAv table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. @@ -1136,7 +1136,7 @@ abstract class BaseFeatureProdPeer * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doCountJoinAllExceptFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; @@ -1163,7 +1163,7 @@ abstract class BaseFeatureProdPeer $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); } - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); @@ -1181,7 +1181,7 @@ abstract class BaseFeatureProdPeer /** - * Selects a collection of FeatureProd objects pre-filled with all related objects except FeatureAv. + * Selects a collection of FeatureProd objects pre-filled with all related objects except Product. * * @param Criteria $criteria * @param PropelPDO $con @@ -1190,7 +1190,7 @@ abstract class BaseFeatureProdPeer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoinAllExceptFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; @@ -1207,12 +1207,12 @@ abstract class BaseFeatureProdPeer FeaturePeer::addSelectColumns($criteria); $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; + FeatureAvPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); @@ -1251,21 +1251,21 @@ abstract class BaseFeatureProdPeer } // if joined row is not null - // Add objects for joined Product rows + // Add objects for joined FeatureAv rows - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); + $key3 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); + $obj3 = FeatureAvPeer::getInstanceFromPool($key3); if (!$obj3) { - $cls = ProductPeer::getOMClass(); + $cls = FeatureAvPeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); + FeatureAvPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded - // Add the $obj1 (FeatureProd) to the collection in $obj3 (Product) + // Add the $obj1 (FeatureProd) to the collection in $obj3 (FeatureAv) $obj3->addFeatureProd($obj1); } // if joined row is not null @@ -1302,16 +1302,16 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addSelectColumns($criteria); $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; + $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + FeatureAvPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $stmt = BasePeer::doSelect($criteria, $con); $results = array(); @@ -1330,40 +1330,40 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded - // Add objects for joined FeatureAv rows + // Add objects for joined Product rows - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); + $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); + $obj2 = ProductPeer::getInstanceFromPool($key2); if (!$obj2) { - $cls = FeatureAvPeer::getOMClass(); + $cls = ProductPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); - FeatureAvPeer::addInstanceToPool($obj2, $key2); + ProductPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded - // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv) + // Add the $obj1 (FeatureProd) to the collection in $obj2 (Product) $obj2->addFeatureProd($obj1); } // if joined row is not null - // Add objects for joined Product rows + // Add objects for joined FeatureAv rows - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); + $key3 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); + $obj3 = FeatureAvPeer::getInstanceFromPool($key3); if (!$obj3) { - $cls = ProductPeer::getOMClass(); + $cls = FeatureAvPeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); + FeatureAvPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded - // Add the $obj1 (FeatureProd) to the collection in $obj3 (Product) + // Add the $obj1 (FeatureProd) to the collection in $obj3 (FeatureAv) $obj3->addFeatureProd($obj1); } // if joined row is not null @@ -1377,7 +1377,7 @@ abstract class BaseFeatureProdPeer /** - * Selects a collection of FeatureProd objects pre-filled with all related objects except Product. + * Selects a collection of FeatureProd objects pre-filled with all related objects except FeatureAv. * * @param Criteria $criteria * @param PropelPDO $con @@ -1386,7 +1386,7 @@ abstract class BaseFeatureProdPeer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public static function doSelectJoinAllExceptFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; @@ -1400,13 +1400,13 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addSelectColumns($criteria); $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; + ProductPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; FeaturePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS; - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); + $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); @@ -1428,21 +1428,21 @@ abstract class BaseFeatureProdPeer FeatureProdPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded - // Add objects for joined FeatureAv rows + // Add objects for joined Product rows - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); + $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); + $obj2 = ProductPeer::getInstanceFromPool($key2); if (!$obj2) { - $cls = FeatureAvPeer::getOMClass(); + $cls = ProductPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); - FeatureAvPeer::addInstanceToPool($obj2, $key2); + ProductPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded - // Add the $obj1 (FeatureProd) to the collection in $obj2 (FeatureAv) + // Add the $obj1 (FeatureProd) to the collection in $obj2 (Product) $obj2->addFeatureProd($obj1); } // if joined row is not null diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php index d8a0daccb..8242d8c5f 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php @@ -28,7 +28,7 @@ use Thelia\Model\Product; * @method FeatureProdQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method FeatureProdQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column * @method FeatureProdQuery orderByFeatureAvId($order = Criteria::ASC) Order by the feature_av_id column - * @method FeatureProdQuery orderByDefaultUtility($order = Criteria::ASC) Order by the default_utility column + * @method FeatureProdQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column * @method FeatureProdQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method FeatureProdQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method FeatureProdQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -37,7 +37,7 @@ use Thelia\Model\Product; * @method FeatureProdQuery groupByProductId() Group by the product_id column * @method FeatureProdQuery groupByFeatureId() Group by the feature_id column * @method FeatureProdQuery groupByFeatureAvId() Group by the feature_av_id column - * @method FeatureProdQuery groupByDefaultUtility() Group by the default_utility column + * @method FeatureProdQuery groupByByDefault() Group by the by_default column * @method FeatureProdQuery groupByPosition() Group by the position column * @method FeatureProdQuery groupByCreatedAt() Group by the created_at column * @method FeatureProdQuery groupByUpdatedAt() Group by the updated_at column @@ -46,17 +46,17 @@ use Thelia\Model\Product; * @method FeatureProdQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method FeatureProdQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method FeatureProdQuery leftJoinFeatureAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAv relation - * @method FeatureProdQuery rightJoinFeatureAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAv relation - * @method FeatureProdQuery innerJoinFeatureAv($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAv relation + * @method FeatureProdQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation + * @method FeatureProdQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation + * @method FeatureProdQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation * * @method FeatureProdQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation * @method FeatureProdQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation * @method FeatureProdQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation * - * @method FeatureProdQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation - * @method FeatureProdQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation - * @method FeatureProdQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation + * @method FeatureProdQuery leftJoinFeatureAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAv relation + * @method FeatureProdQuery rightJoinFeatureAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAv relation + * @method FeatureProdQuery innerJoinFeatureAv($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAv relation * * @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 @@ -65,7 +65,7 @@ use Thelia\Model\Product; * @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 - * @method FeatureProd findOneByDefaultUtility(string $default_utility) Return the first FeatureProd filtered by the default_utility column + * @method FeatureProd findOneByByDefault(string $by_default) Return the first FeatureProd filtered by the by_default column * @method FeatureProd findOneByPosition(int $position) Return the first FeatureProd filtered by the position column * @method FeatureProd findOneByCreatedAt(string $created_at) Return the first FeatureProd filtered by the created_at column * @method FeatureProd findOneByUpdatedAt(string $updated_at) Return the first FeatureProd filtered by the updated_at column @@ -74,7 +74,7 @@ use Thelia\Model\Product; * @method array findByProductId(int $product_id) Return FeatureProd objects filtered by the product_id column * @method array findByFeatureId(int $feature_id) Return FeatureProd objects filtered by the feature_id column * @method array findByFeatureAvId(int $feature_av_id) Return FeatureProd objects filtered by the feature_av_id column - * @method array findByDefaultUtility(string $default_utility) Return FeatureProd objects filtered by the default_utility column + * @method array findByByDefault(string $by_default) Return FeatureProd objects filtered by the by_default column * @method array findByPosition(int $position) Return FeatureProd objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return FeatureProd objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return FeatureProd objects filtered by the updated_at column @@ -167,7 +167,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `FEATURE_ID`, `FEATURE_AV_ID`, `DEFAULT_UTILITY`, `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); @@ -413,32 +413,32 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } /** - * Filter the query on the default_utility column + * Filter the query on the by_default column * * Example usage: * - * $query->filterByDefaultUtility('fooValue'); // WHERE default_utility = 'fooValue' - * $query->filterByDefaultUtility('%fooValue%'); // WHERE default_utility LIKE '%fooValue%' + * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue' + * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%' * * - * @param string $defaultUtility The value to use as filter. + * @param string $byDefault The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return FeatureProdQuery The current query, for fluid interface */ - public function filterByDefaultUtility($defaultUtility = null, $comparison = null) + public function filterByByDefault($byDefault = null, $comparison = null) { if (null === $comparison) { - if (is_array($defaultUtility)) { + if (is_array($byDefault)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $defaultUtility)) { - $defaultUtility = str_replace('*', '%', $defaultUtility); + } elseif (preg_match('/[\%\*]/', $byDefault)) { + $byDefault = str_replace('*', '%', $byDefault); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(FeatureProdPeer::DEFAULT_UTILITY, $defaultUtility, $comparison); + return $this->addUsingAlias(FeatureProdPeer::BY_DEFAULT, $byDefault, $comparison); } /** @@ -569,43 +569,43 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } /** - * Filter the query by a related FeatureAv object + * Filter the query by a related Product object * - * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter + * @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. */ - public function filterByFeatureAv($featureAv, $comparison = null) + public function filterByProduct($product, $comparison = null) { - if ($featureAv instanceof FeatureAv) { + if ($product instanceof Product) { return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the FeatureAv relation + * Adds a JOIN clause to the query using the Product relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return FeatureProdQuery The current query, for fluid interface */ - public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAv'); + $relationMap = $tableMap->getRelation('Product'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -620,14 +620,14 @@ abstract class BaseFeatureProdQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'FeatureAv'); + $this->addJoinObject($join, 'Product'); } return $this; } /** - * Use the FeatureAv relation FeatureAv object + * Use the Product relation Product object * * @see useQuery() * @@ -635,13 +635,13 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query */ - public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinFeatureAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); } /** @@ -721,43 +721,43 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } /** - * Filter the query by a related Product object + * Filter the query by a related FeatureAv object * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter + * @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. */ - public function filterByProduct($product, $comparison = null) + public function filterByFeatureAv($featureAv, $comparison = null) { - if ($product instanceof Product) { + if ($featureAv instanceof FeatureAv) { return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison); + } elseif ($featureAv instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the Product relation + * Adds a JOIN clause to the query using the FeatureAv relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return FeatureProdQuery The current query, for fluid interface */ - public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); + $relationMap = $tableMap->getRelation('FeatureAv'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -772,14 +772,14 @@ abstract class BaseFeatureProdQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Product'); + $this->addJoinObject($join, 'FeatureAv'); } return $this; } /** - * Use the Product relation Product object + * Use the FeatureAv relation FeatureAv object * * @see useQuery() * @@ -787,13 +787,13 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + ->joinFeatureAv($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); } /** @@ -812,4 +812,69 @@ abstract class BaseFeatureProdQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureProdPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureProdPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeatureProdPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureProdPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureProdQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureProdPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/om/BaseFeatureQuery.php index 8693b761e..edb1625c7 100644 --- a/core/lib/Thelia/Model/om/BaseFeatureQuery.php +++ b/core/lib/Thelia/Model/om/BaseFeatureQuery.php @@ -41,22 +41,22 @@ use Thelia\Model\FeatureQuery; * @method FeatureQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method FeatureQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method FeatureQuery leftJoinFeatureAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAv relation - * @method FeatureQuery rightJoinFeatureAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAv relation - * @method FeatureQuery innerJoinFeatureAv($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAv relation - * - * @method FeatureQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation - * @method FeatureQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation - * @method FeatureQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation - * * @method FeatureQuery leftJoinFeatureDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureDesc relation * @method FeatureQuery rightJoinFeatureDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureDesc relation * @method FeatureQuery innerJoinFeatureDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureDesc relation * + * @method FeatureQuery leftJoinFeatureAv($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureAv relation + * @method FeatureQuery rightJoinFeatureAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureAv relation + * @method FeatureQuery innerJoinFeatureAv($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureAv relation + * * @method FeatureQuery leftJoinFeatureProd($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureProd relation * @method FeatureQuery rightJoinFeatureProd($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProd relation * @method FeatureQuery innerJoinFeatureProd($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProd relation * + * @method FeatureQuery leftJoinFeatureCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureCategory relation + * @method FeatureQuery rightJoinFeatureCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureCategory relation + * @method FeatureQuery innerJoinFeatureCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureCategory relation + * * @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 * @@ -444,154 +444,6 @@ abstract class BaseFeatureQuery extends ModelCriteria return $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related FeatureAv object - * - * @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. - */ - public function filterByFeatureAv($featureAv, $comparison = null) - { - if ($featureAv instanceof FeatureAv) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { - return $this - ->useFeatureAvQuery() - ->filterByPrimaryKeys($featureAv->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureAv'); - } - - return $this; - } - - /** - * Use the FeatureAv relation FeatureAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query - */ - public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); - } - - /** - * Filter the query by a related FeatureCategory object - * - * @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. - */ - public function filterByFeatureCategory($featureCategory, $comparison = null) - { - if ($featureCategory instanceof FeatureCategory) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison); - } elseif ($featureCategory instanceof PropelObjectCollection) { - return $this - ->useFeatureCategoryQuery() - ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureCategory'); - } - - return $this; - } - - /** - * Use the FeatureCategory relation FeatureCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query - */ - public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); - } - /** * Filter the query by a related FeatureDesc object * @@ -666,6 +518,80 @@ abstract class BaseFeatureQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'FeatureDesc', '\Thelia\Model\FeatureDescQuery'); } + /** + * Filter the query by a related FeatureAv object + * + * @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. + */ + public function filterByFeatureAv($featureAv, $comparison = null) + { + if ($featureAv instanceof FeatureAv) { + return $this + ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison); + } elseif ($featureAv instanceof PropelObjectCollection) { + return $this + ->useFeatureAvQuery() + ->filterByPrimaryKeys($featureAv->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the FeatureAv relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return FeatureQuery The current query, for fluid interface + */ + public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FeatureAv'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FeatureAv'); + } + + return $this; + } + + /** + * Use the FeatureAv relation FeatureAv object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query + */ + public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFeatureAv($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); + } + /** * Filter the query by a related FeatureProd object * @@ -740,6 +666,80 @@ abstract class BaseFeatureQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); } + /** + * Filter the query by a related FeatureCategory object + * + * @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. + */ + public function filterByFeatureCategory($featureCategory, $comparison = null) + { + if ($featureCategory instanceof FeatureCategory) { + return $this + ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison); + } elseif ($featureCategory instanceof PropelObjectCollection) { + return $this + ->useFeatureCategoryQuery() + ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the FeatureCategory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return FeatureQuery The current query, for fluid interface + */ + public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FeatureCategory'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FeatureCategory'); + } + + return $this; + } + + /** + * Use the FeatureCategory relation FeatureCategory object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query + */ + public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFeatureCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); + } + /** * Exclude object from result * @@ -756,4 +756,69 @@ abstract class BaseFeatureQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FeatureQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FeaturePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FeatureQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeaturePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FeatureQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeaturePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FeatureQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FeaturePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FeatureQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FeaturePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FeatureQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FeaturePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php index 21df7c4de..f2f77ba1e 100644 --- a/core/lib/Thelia/Model/om/BaseFolder.php +++ b/core/lib/Thelia/Model/om/BaseFolder.php @@ -99,18 +99,6 @@ abstract class BaseFolder extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects. - */ - protected $collContentFolders; - protected $collContentFoldersPartial; - - /** - * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; - /** * @var PropelObjectCollection|FolderDesc[] Collection to store aggregation of FolderDesc objects. */ @@ -123,12 +111,24 @@ abstract class BaseFolder extends BaseObject implements Persistent protected $collImages; protected $collImagesPartial; + /** + * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. + */ + protected $collDocuments; + protected $collDocumentsPartial; + /** * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects. */ protected $collRewritings; protected $collRewritingsPartial; + /** + * @var PropelObjectCollection|ContentFolder[] Collection to store aggregation of ContentFolder objects. + */ + protected $collContentFolders; + protected $collContentFoldersPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -143,18 +143,6 @@ abstract class BaseFolder extends BaseObject implements Persistent */ protected $alreadyInValidation = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $contentFoldersScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $documentsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -167,12 +155,24 @@ abstract class BaseFolder extends BaseObject implements Persistent */ protected $imagesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $documentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ protected $rewritingsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $contentFoldersScheduledForDeletion = null; + /** * Get the [id] column value. * @@ -557,16 +557,16 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collContentFolders = null; - - $this->collDocuments = null; - $this->collFolderDescs = null; $this->collImages = null; + $this->collDocuments = null; + $this->collRewritings = null; + $this->collContentFolders = null; + } // if (deep) } @@ -639,8 +639,19 @@ abstract class BaseFolder extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FolderPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FolderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FolderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -691,41 +702,6 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->resetModified(); } - if ($this->contentFoldersScheduledForDeletion !== null) { - if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() - ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentFoldersScheduledForDeletion = null; - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->folderDescsScheduledForDeletion !== null) { if (!$this->folderDescsScheduledForDeletion->isEmpty()) { FolderDescQuery::create() @@ -761,6 +737,24 @@ abstract class BaseFolder extends BaseObject implements Persistent } } + if ($this->documentsScheduledForDeletion !== null) { + if (!$this->documentsScheduledForDeletion->isEmpty()) { + foreach ($this->documentsScheduledForDeletion as $document) { + // need to save related object because we set the relation to null + $document->save($con); + } + $this->documentsScheduledForDeletion = null; + } + } + + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { foreach ($this->rewritingsScheduledForDeletion as $rewriting) { @@ -779,6 +773,23 @@ abstract class BaseFolder extends BaseObject implements Persistent } } + if ($this->contentFoldersScheduledForDeletion !== null) { + if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { + ContentFolderQuery::create() + ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->contentFoldersScheduledForDeletion = null; + } + } + + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -957,22 +968,6 @@ abstract class BaseFolder extends BaseObject implements Persistent } - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collFolderDescs !== null) { foreach ($this->collFolderDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -989,6 +984,14 @@ abstract class BaseFolder extends BaseObject implements Persistent } } + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -997,6 +1000,14 @@ abstract class BaseFolder extends BaseObject implements Persistent } } + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + $this->alreadyInValidation = false; } @@ -1091,21 +1102,21 @@ abstract class BaseFolder extends BaseObject implements Persistent $keys[6] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collContentFolders) { - $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collFolderDescs) { $result['FolderDescs'] = $this->collFolderDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collImages) { $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collDocuments) { + $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collContentFolders) { + $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1287,18 +1298,6 @@ abstract class BaseFolder extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getContentFolders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentFolder($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - foreach ($this->getFolderDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addFolderDesc($relObj->copy($deepCopy)); @@ -1311,12 +1310,24 @@ abstract class BaseFolder extends BaseObject implements Persistent } } + foreach ($this->getDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); } } + foreach ($this->getContentFolders() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentFolder($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1378,535 +1389,21 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('ContentFolder' == $relationName) { - $this->initContentFolders(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } if ('FolderDesc' == $relationName) { $this->initFolderDescs(); } if ('Image' == $relationName) { $this->initImages(); } + if ('Document' == $relationName) { + $this->initDocuments(); + } if ('Rewriting' == $relationName) { $this->initRewritings(); } - } - - /** - * Clears out the collContentFolders collection - * - * 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 - * @see addContentFolders() - */ - public function clearContentFolders() - { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - } - - /** - * reset is the collContentFolders collection loaded partially - * - * @return void - */ - public function resetPartialContentFolders($v = true) - { - $this->collContentFoldersPartial = $v; - } - - /** - * Initializes the collContentFolders collection. - * - * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentFolders($overrideExisting = true) - { - if (null !== $this->collContentFolders && !$overrideExisting) { - return; - } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); - } - - /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - * @throws PropelException - */ - public function getContentFolders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - // return empty collection - $this->initContentFolders(); - } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); - - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); - } - } - - $this->collContentFoldersPartial = true; - } - - return $collContentFolders; - } - - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { - $collContentFolders[] = $obj; - } - } - } - - $this->collContentFolders = $collContentFolders; - $this->collContentFoldersPartial = false; - } - } - - return $this->collContentFolders; - } - - /** - * Sets a collection of ContentFolder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentFolders A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) - { - $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - - foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { - $contentFolderRemoved->setFolder(null); - } - - $this->collContentFolders = null; - foreach ($contentFolders as $contentFolder) { - $this->addContentFolder($contentFolder); - } - - $this->collContentFolders = $contentFolders; - $this->collContentFoldersPartial = false; - } - - /** - * Returns the number of related ContentFolder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentFolder objects. - * @throws PropelException - */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. - * - * @param ContentFolder $l ContentFolder - * @return Folder The current object (for fluent API support) - */ - public function addContentFolder(ContentFolder $l) - { - if ($this->collContentFolders === null) { + if ('ContentFolder' == $relationName) { $this->initContentFolders(); - $this->collContentFoldersPartial = true; } - if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddContentFolder($l); - } - - return $this; - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to add. - */ - protected function doAddContentFolder($contentFolder) - { - $this->collContentFolders[]= $contentFolder; - $contentFolder->setFolder($this); - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - */ - public function removeContentFolder($contentFolder) - { - if ($this->getContentFolders()->contains($contentFolder)) { - $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); - if (null === $this->contentFoldersScheduledForDeletion) { - $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; - $this->contentFoldersScheduledForDeletion->clear(); - } - $this->contentFoldersScheduledForDeletion[]= $contentFolder; - $contentFolder->setFolder(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related ContentFolders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - */ - public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getContentFolders($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * 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 - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); - - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { - $documentRemoved->setFolder(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Folder The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setFolder($this); - } - - /** - * @param Document $document The document object to remove. - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setFolder(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); } /** @@ -2398,6 +1895,288 @@ abstract class BaseFolder extends BaseObject implements Persistent return $this->getImages($query, $con); } + /** + * Clears out the collDocuments collection + * + * 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 + * @see addDocuments() + */ + public function clearDocuments() + { + $this->collDocuments = null; // important to set this to null since that means it is uninitialized + $this->collDocumentsPartial = null; + } + + /** + * reset is the collDocuments collection loaded partially + * + * @return void + */ + public function resetPartialDocuments($v = true) + { + $this->collDocumentsPartial = $v; + } + + /** + * Initializes the collDocuments collection. + * + * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initDocuments($overrideExisting = true) + { + if (null !== $this->collDocuments && !$overrideExisting) { + return; + } + $this->collDocuments = new PropelObjectCollection(); + $this->collDocuments->setModel('Document'); + } + + /** + * Gets an array of Document objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Folder is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Document[] List of Document objects + * @throws PropelException + */ + public function getDocuments($criteria = null, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + if (null === $this->collDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collDocuments) { + // return empty collection + $this->initDocuments(); + } else { + $collDocuments = DocumentQuery::create(null, $criteria) + ->filterByFolder($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collDocumentsPartial && count($collDocuments)) { + $this->initDocuments(false); + + foreach($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } + } + + $this->collDocumentsPartial = true; + } + + return $collDocuments; + } + + if($partial && $this->collDocuments) { + foreach($this->collDocuments as $obj) { + if($obj->isNew()) { + $collDocuments[] = $obj; + } + } + } + + $this->collDocuments = $collDocuments; + $this->collDocumentsPartial = false; + } + } + + return $this->collDocuments; + } + + /** + * Sets a collection of Document objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $documents A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + { + $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + + foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $documentRemoved->setFolder(null); + } + + $this->collDocuments = null; + foreach ($documents as $document) { + $this->addDocument($document); + } + + $this->collDocuments = $documents; + $this->collDocumentsPartial = false; + } + + /** + * Returns the number of related Document objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Document objects. + * @throws PropelException + */ + public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Document object to this object + * through the Document foreign key attribute. + * + * @param Document $l Document + * @return Folder The current object (for fluent API support) + */ + public function addDocument(Document $l) + { + if ($this->collDocuments === null) { + $this->initDocuments(); + $this->collDocumentsPartial = true; + } + if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddDocument($l); + } + + return $this; + } + + /** + * @param Document $document The document object to add. + */ + protected function doAddDocument($document) + { + $this->collDocuments[]= $document; + $document->setFolder($this); + } + + /** + * @param Document $document The document object to remove. + */ + public function removeDocument($document) + { + if ($this->getDocuments()->contains($document)) { + $this->collDocuments->remove($this->collDocuments->search($document)); + if (null === $this->documentsScheduledForDeletion) { + $this->documentsScheduledForDeletion = clone $this->collDocuments; + $this->documentsScheduledForDeletion->clear(); + } + $this->documentsScheduledForDeletion[]= $document; + $document->setFolder(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Folder is new, it will return + * an empty collection; or if this Folder has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Folder. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Product', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Folder is new, it will return + * an empty collection; or if this Folder has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Folder. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Folder is new, it will return + * an empty collection; or if this Folder has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Folder. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getDocuments($query, $con); + } + /** * Clears out the collRewritings collection * @@ -2680,6 +2459,238 @@ abstract class BaseFolder extends BaseObject implements Persistent return $this->getRewritings($query, $con); } + /** + * Clears out the collContentFolders collection + * + * 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 + * @see addContentFolders() + */ + public function clearContentFolders() + { + $this->collContentFolders = null; // important to set this to null since that means it is uninitialized + $this->collContentFoldersPartial = null; + } + + /** + * reset is the collContentFolders collection loaded partially + * + * @return void + */ + public function resetPartialContentFolders($v = true) + { + $this->collContentFoldersPartial = $v; + } + + /** + * Initializes the collContentFolders collection. + * + * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentFolders($overrideExisting = true) + { + if (null !== $this->collContentFolders && !$overrideExisting) { + return; + } + $this->collContentFolders = new PropelObjectCollection(); + $this->collContentFolders->setModel('ContentFolder'); + } + + /** + * Gets an array of ContentFolder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Folder is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects + * @throws PropelException + */ + public function getContentFolders($criteria = null, PropelPDO $con = null) + { + $partial = $this->collContentFoldersPartial && !$this->isNew(); + if (null === $this->collContentFolders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentFolders) { + // return empty collection + $this->initContentFolders(); + } else { + $collContentFolders = ContentFolderQuery::create(null, $criteria) + ->filterByFolder($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { + $this->initContentFolders(false); + + foreach($collContentFolders as $obj) { + if (false == $this->collContentFolders->contains($obj)) { + $this->collContentFolders->append($obj); + } + } + + $this->collContentFoldersPartial = true; + } + + return $collContentFolders; + } + + if($partial && $this->collContentFolders) { + foreach($this->collContentFolders as $obj) { + if($obj->isNew()) { + $collContentFolders[] = $obj; + } + } + } + + $this->collContentFolders = $collContentFolders; + $this->collContentFoldersPartial = false; + } + } + + return $this->collContentFolders; + } + + /** + * Sets a collection of ContentFolder objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $contentFolders A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) + { + $this->contentFoldersScheduledForDeletion = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); + + foreach ($this->contentFoldersScheduledForDeletion as $contentFolderRemoved) { + $contentFolderRemoved->setFolder(null); + } + + $this->collContentFolders = null; + foreach ($contentFolders as $contentFolder) { + $this->addContentFolder($contentFolder); + } + + $this->collContentFolders = $contentFolders; + $this->collContentFoldersPartial = false; + } + + /** + * Returns the number of related ContentFolder objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ContentFolder objects. + * @throws PropelException + */ + public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collContentFoldersPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a ContentFolder object to this object + * through the ContentFolder foreign key attribute. + * + * @param ContentFolder $l ContentFolder + * @return Folder The current object (for fluent API support) + */ + public function addContentFolder(ContentFolder $l) + { + if ($this->collContentFolders === null) { + $this->initContentFolders(); + $this->collContentFoldersPartial = true; + } + if (!$this->collContentFolders->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddContentFolder($l); + } + + return $this; + } + + /** + * @param ContentFolder $contentFolder The contentFolder object to add. + */ + protected function doAddContentFolder($contentFolder) + { + $this->collContentFolders[]= $contentFolder; + $contentFolder->setFolder($this); + } + + /** + * @param ContentFolder $contentFolder The contentFolder object to remove. + */ + public function removeContentFolder($contentFolder) + { + if ($this->getContentFolders()->contains($contentFolder)) { + $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); + if (null === $this->contentFoldersScheduledForDeletion) { + $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; + $this->contentFoldersScheduledForDeletion->clear(); + } + $this->contentFoldersScheduledForDeletion[]= $contentFolder; + $contentFolder->setFolder(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Folder is new, it will return + * an empty collection; or if this Folder has previously + * been saved, it will retrieve related ContentFolders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Folder. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects + */ + public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ContentFolderQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getContentFolders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -2712,16 +2723,6 @@ abstract class BaseFolder extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collContentFolders) { - foreach ($this->collContentFolders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collFolderDescs) { foreach ($this->collFolderDescs as $o) { $o->clearAllReferences($deep); @@ -2732,21 +2733,23 @@ abstract class BaseFolder extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->collDocuments) { + foreach ($this->collDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); } } + if ($this->collContentFolders) { + foreach ($this->collContentFolders as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collContentFolders instanceof PropelCollection) { - $this->collContentFolders->clearIterator(); - } - $this->collContentFolders = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; if ($this->collFolderDescs instanceof PropelCollection) { $this->collFolderDescs->clearIterator(); } @@ -2755,10 +2758,18 @@ abstract class BaseFolder extends BaseObject implements Persistent $this->collImages->clearIterator(); } $this->collImages = null; + if ($this->collDocuments instanceof PropelCollection) { + $this->collDocuments->clearIterator(); + } + $this->collDocuments = null; if ($this->collRewritings instanceof PropelCollection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; + if ($this->collContentFolders instanceof PropelCollection) { + $this->collContentFolders->clearIterator(); + } + $this->collContentFolders = null; } /** @@ -2781,4 +2792,18 @@ abstract class BaseFolder extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Folder The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FolderPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFolderDesc.php b/core/lib/Thelia/Model/om/BaseFolderDesc.php index 39392a103..e5d247e8d 100644 --- a/core/lib/Thelia/Model/om/BaseFolderDesc.php +++ b/core/lib/Thelia/Model/om/BaseFolderDesc.php @@ -648,8 +648,19 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FolderDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FolderDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FolderDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1372,4 +1383,18 @@ abstract class BaseFolderDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return FolderDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FolderDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseFolderDescQuery.php b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php index 761634ea3..f7af60c28 100644 --- a/core/lib/Thelia/Model/om/BaseFolderDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseFolderDescQuery.php @@ -643,4 +643,69 @@ abstract class BaseFolderDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FolderDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FolderDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FolderDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FolderDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FolderDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FolderDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FolderDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php index 6a45fb85b..78f7cb4bd 100644 --- a/core/lib/Thelia/Model/om/BaseFolderPeer.php +++ b/core/lib/Thelia/Model/om/BaseFolderPeer.php @@ -397,21 +397,21 @@ abstract class BaseFolderPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in ContentFolderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentFolderPeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); // Invalidate objects in FolderDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. FolderDescPeer::clearInstancePool(); // Invalidate objects in ImagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ImagePeer::clearInstancePool(); + // Invalidate objects in DocumentPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + DocumentPeer::clearInstancePool(); // Invalidate objects in RewritingPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RewritingPeer::clearInstancePool(); + // Invalidate objects in ContentFolderPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentFolderPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php index d4e88949a..75b3fc50b 100644 --- a/core/lib/Thelia/Model/om/BaseFolderQuery.php +++ b/core/lib/Thelia/Model/om/BaseFolderQuery.php @@ -46,14 +46,6 @@ use Thelia\Model\Rewriting; * @method FolderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method FolderQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method FolderQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation - * @method FolderQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation - * @method FolderQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation - * - * @method FolderQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method FolderQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method FolderQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation - * * @method FolderQuery leftJoinFolderDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderDesc relation * @method FolderQuery rightJoinFolderDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderDesc relation * @method FolderQuery innerJoinFolderDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderDesc relation @@ -62,10 +54,18 @@ use Thelia\Model\Rewriting; * @method FolderQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation * @method FolderQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation * + * @method FolderQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation + * @method FolderQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation + * @method FolderQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * * @method FolderQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method FolderQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method FolderQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation * + * @method FolderQuery leftJoinContentFolder($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentFolder relation + * @method FolderQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation + * @method FolderQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation + * * @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 * @@ -527,154 +527,6 @@ abstract class BaseFolderQuery extends ModelCriteria return $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related ContentFolder object - * - * @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. - */ - public function filterByContentFolder($contentFolder, $comparison = null) - { - if ($contentFolder instanceof ContentFolder) { - return $this - ->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { - return $this - ->useContentFolderQuery() - ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentFolder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentFolder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentFolder'); - } - - return $this; - } - - /** - * Use the ContentFolder relation ContentFolder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query - */ - public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinContentFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); - } - - /** - * Filter the query by a related Document object - * - * @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. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - /** * Filter the query by a related FolderDesc object * @@ -823,6 +675,80 @@ abstract class BaseFolderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); } + /** + * Filter the query by a related Document object + * + * @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. + */ + public function filterByDocument($document, $comparison = null) + { + if ($document instanceof Document) { + return $this + ->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison); + } elseif ($document instanceof PropelObjectCollection) { + return $this + ->useDocumentQuery() + ->filterByPrimaryKeys($document->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Document relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return FolderQuery The current query, for fluid interface + */ + public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Document'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Document'); + } + + return $this; + } + + /** + * Use the Document relation Document object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query + */ + public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + } + /** * Filter the query by a related Rewriting object * @@ -897,6 +823,80 @@ abstract class BaseFolderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); } + /** + * Filter the query by a related ContentFolder object + * + * @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. + */ + public function filterByContentFolder($contentFolder, $comparison = null) + { + if ($contentFolder instanceof ContentFolder) { + return $this + ->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison); + } elseif ($contentFolder instanceof PropelObjectCollection) { + return $this + ->useContentFolderQuery() + ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentFolder relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return FolderQuery The current query, for fluid interface + */ + public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentFolder'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentFolder'); + } + + return $this; + } + + /** + * Use the ContentFolder relation ContentFolder object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query + */ + public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContentFolder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); + } + /** * Exclude object from result * @@ -913,4 +913,69 @@ abstract class BaseFolderQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return FolderQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FolderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return FolderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FolderPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return FolderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FolderPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return FolderQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FolderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return FolderQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FolderPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return FolderQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FolderPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseGroup.php b/core/lib/Thelia/Model/om/BaseGroup.php index 48895894a..c0b23863b 100644 --- a/core/lib/Thelia/Model/om/BaseGroup.php +++ b/core/lib/Thelia/Model/om/BaseGroup.php @@ -79,12 +79,6 @@ abstract class BaseGroup extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|AdminGroup[] Collection to store aggregation of AdminGroup objects. - */ - protected $collAdminGroups; - protected $collAdminGroupsPartial; - /** * @var PropelObjectCollection|GroupDesc[] Collection to store aggregation of GroupDesc objects. */ @@ -92,10 +86,10 @@ abstract class BaseGroup extends BaseObject implements Persistent protected $collGroupDescsPartial; /** - * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects. + * @var PropelObjectCollection|AdminGroup[] Collection to store aggregation of AdminGroup objects. */ - protected $collGroupModules; - protected $collGroupModulesPartial; + protected $collAdminGroups; + protected $collAdminGroupsPartial; /** * @var PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects. @@ -103,6 +97,12 @@ abstract class BaseGroup extends BaseObject implements Persistent protected $collGroupResources; protected $collGroupResourcesPartial; + /** + * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects. + */ + protected $collGroupModules; + protected $collGroupModulesPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -117,12 +117,6 @@ abstract class BaseGroup extends BaseObject implements Persistent */ protected $alreadyInValidation = false; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $adminGroupsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -133,7 +127,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $groupModulesScheduledForDeletion = null; + protected $adminGroupsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -141,6 +135,12 @@ abstract class BaseGroup extends BaseObject implements Persistent */ protected $groupResourcesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $groupModulesScheduledForDeletion = null; + /** * Get the [id] column value. * @@ -429,14 +429,14 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collAdminGroups = null; - $this->collGroupDescs = null; - $this->collGroupModules = null; + $this->collAdminGroups = null; $this->collGroupResources = null; + $this->collGroupModules = null; + } // if (deep) } @@ -509,8 +509,19 @@ abstract class BaseGroup extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -561,6 +572,23 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->resetModified(); } + if ($this->groupDescsScheduledForDeletion !== null) { + if (!$this->groupDescsScheduledForDeletion->isEmpty()) { + GroupDescQuery::create() + ->filterByPrimaryKeys($this->groupDescsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->groupDescsScheduledForDeletion = null; + } + } + + if ($this->collGroupDescs !== null) { + foreach ($this->collGroupDescs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->adminGroupsScheduledForDeletion !== null) { if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { foreach ($this->adminGroupsScheduledForDeletion as $adminGroup) { @@ -579,17 +607,17 @@ abstract class BaseGroup extends BaseObject implements Persistent } } - if ($this->groupDescsScheduledForDeletion !== null) { - if (!$this->groupDescsScheduledForDeletion->isEmpty()) { - GroupDescQuery::create() - ->filterByPrimaryKeys($this->groupDescsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->groupResourcesScheduledForDeletion !== null) { + if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { + GroupResourceQuery::create() + ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->groupDescsScheduledForDeletion = null; + $this->groupResourcesScheduledForDeletion = null; } } - if ($this->collGroupDescs !== null) { - foreach ($this->collGroupDescs as $referrerFK) { + if ($this->collGroupResources !== null) { + foreach ($this->collGroupResources as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } @@ -613,23 +641,6 @@ abstract class BaseGroup extends BaseObject implements Persistent } } - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupResourcesScheduledForDeletion = null; - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - $this->alreadyInSave = false; } @@ -790,14 +801,6 @@ abstract class BaseGroup extends BaseObject implements Persistent } - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collGroupDescs !== null) { foreach ($this->collGroupDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -806,8 +809,8 @@ abstract class BaseGroup extends BaseObject implements Persistent } } - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { + if ($this->collAdminGroups !== null) { + foreach ($this->collAdminGroups as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -822,6 +825,14 @@ abstract class BaseGroup extends BaseObject implements Persistent } } + if ($this->collGroupModules !== null) { + foreach ($this->collGroupModules as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + $this->alreadyInValidation = false; } @@ -904,18 +915,18 @@ abstract class BaseGroup extends BaseObject implements Persistent $keys[3] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collAdminGroups) { - $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collGroupDescs) { $result['GroupDescs'] = $this->collGroupDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAdminGroups) { + $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collGroupResources) { $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collGroupModules) { + $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1079,21 +1090,15 @@ abstract class BaseGroup extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getAdminGroups() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAdminGroup($relObj->copy($deepCopy)); - } - } - foreach ($this->getGroupDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addGroupDesc($relObj->copy($deepCopy)); } } - foreach ($this->getGroupModules() as $relObj) { + foreach ($this->getAdminGroups() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); + $copyObj->addAdminGroup($relObj->copy($deepCopy)); } } @@ -1103,6 +1108,12 @@ abstract class BaseGroup extends BaseObject implements Persistent } } + foreach ($this->getGroupModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addGroupModule($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1164,17 +1175,224 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('GroupDesc' == $relationName) { + $this->initGroupDescs(); + } if ('AdminGroup' == $relationName) { $this->initAdminGroups(); } - if ('GroupDesc' == $relationName) { - $this->initGroupDescs(); + if ('GroupResource' == $relationName) { + $this->initGroupResources(); } if ('GroupModule' == $relationName) { $this->initGroupModules(); } - if ('GroupResource' == $relationName) { - $this->initGroupResources(); + } + + /** + * Clears out the collGroupDescs collection + * + * 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 + * @see addGroupDescs() + */ + public function clearGroupDescs() + { + $this->collGroupDescs = null; // important to set this to null since that means it is uninitialized + $this->collGroupDescsPartial = null; + } + + /** + * reset is the collGroupDescs collection loaded partially + * + * @return void + */ + public function resetPartialGroupDescs($v = true) + { + $this->collGroupDescsPartial = $v; + } + + /** + * Initializes the collGroupDescs collection. + * + * By default this just sets the collGroupDescs collection to an empty array (like clearcollGroupDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initGroupDescs($overrideExisting = true) + { + if (null !== $this->collGroupDescs && !$overrideExisting) { + return; + } + $this->collGroupDescs = new PropelObjectCollection(); + $this->collGroupDescs->setModel('GroupDesc'); + } + + /** + * Gets an array of GroupDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Group is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|GroupDesc[] List of GroupDesc objects + * @throws PropelException + */ + public function getGroupDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collGroupDescsPartial && !$this->isNew(); + if (null === $this->collGroupDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collGroupDescs) { + // return empty collection + $this->initGroupDescs(); + } else { + $collGroupDescs = GroupDescQuery::create(null, $criteria) + ->filterByGroup($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collGroupDescsPartial && count($collGroupDescs)) { + $this->initGroupDescs(false); + + foreach($collGroupDescs as $obj) { + if (false == $this->collGroupDescs->contains($obj)) { + $this->collGroupDescs->append($obj); + } + } + + $this->collGroupDescsPartial = true; + } + + return $collGroupDescs; + } + + if($partial && $this->collGroupDescs) { + foreach($this->collGroupDescs as $obj) { + if($obj->isNew()) { + $collGroupDescs[] = $obj; + } + } + } + + $this->collGroupDescs = $collGroupDescs; + $this->collGroupDescsPartial = false; + } + } + + return $this->collGroupDescs; + } + + /** + * Sets a collection of GroupDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $groupDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setGroupDescs(PropelCollection $groupDescs, PropelPDO $con = null) + { + $this->groupDescsScheduledForDeletion = $this->getGroupDescs(new Criteria(), $con)->diff($groupDescs); + + foreach ($this->groupDescsScheduledForDeletion as $groupDescRemoved) { + $groupDescRemoved->setGroup(null); + } + + $this->collGroupDescs = null; + foreach ($groupDescs as $groupDesc) { + $this->addGroupDesc($groupDesc); + } + + $this->collGroupDescs = $groupDescs; + $this->collGroupDescsPartial = false; + } + + /** + * Returns the number of related GroupDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related GroupDesc objects. + * @throws PropelException + */ + public function countGroupDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collGroupDescsPartial && !$this->isNew(); + if (null === $this->collGroupDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collGroupDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getGroupDescs()); + } + $query = GroupDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByGroup($this) + ->count($con); + } + } else { + return count($this->collGroupDescs); + } + } + + /** + * Method called to associate a GroupDesc object to this object + * through the GroupDesc foreign key attribute. + * + * @param GroupDesc $l GroupDesc + * @return Group The current object (for fluent API support) + */ + public function addGroupDesc(GroupDesc $l) + { + if ($this->collGroupDescs === null) { + $this->initGroupDescs(); + $this->collGroupDescsPartial = true; + } + if (!$this->collGroupDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddGroupDesc($l); + } + + return $this; + } + + /** + * @param GroupDesc $groupDesc The groupDesc object to add. + */ + protected function doAddGroupDesc($groupDesc) + { + $this->collGroupDescs[]= $groupDesc; + $groupDesc->setGroup($this); + } + + /** + * @param GroupDesc $groupDesc The groupDesc object to remove. + */ + public function removeGroupDesc($groupDesc) + { + if ($this->getGroupDescs()->contains($groupDesc)) { + $this->collGroupDescs->remove($this->collGroupDescs->search($groupDesc)); + if (null === $this->groupDescsScheduledForDeletion) { + $this->groupDescsScheduledForDeletion = clone $this->collGroupDescs; + $this->groupDescsScheduledForDeletion->clear(); + } + $this->groupDescsScheduledForDeletion[]= $groupDesc; + $groupDesc->setGroup(null); } } @@ -1411,34 +1629,34 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Clears out the collGroupDescs collection + * Clears out the collGroupResources collection * * 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 - * @see addGroupDescs() + * @see addGroupResources() */ - public function clearGroupDescs() + public function clearGroupResources() { - $this->collGroupDescs = null; // important to set this to null since that means it is uninitialized - $this->collGroupDescsPartial = null; + $this->collGroupResources = null; // important to set this to null since that means it is uninitialized + $this->collGroupResourcesPartial = null; } /** - * reset is the collGroupDescs collection loaded partially + * reset is the collGroupResources collection loaded partially * * @return void */ - public function resetPartialGroupDescs($v = true) + public function resetPartialGroupResources($v = true) { - $this->collGroupDescsPartial = $v; + $this->collGroupResourcesPartial = $v; } /** - * Initializes the collGroupDescs collection. + * Initializes the collGroupResources collection. * - * By default this just sets the collGroupDescs collection to an empty array (like clearcollGroupDescs()); + * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1447,17 +1665,17 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @return void */ - public function initGroupDescs($overrideExisting = true) + public function initGroupResources($overrideExisting = true) { - if (null !== $this->collGroupDescs && !$overrideExisting) { + if (null !== $this->collGroupResources && !$overrideExisting) { return; } - $this->collGroupDescs = new PropelObjectCollection(); - $this->collGroupDescs->setModel('GroupDesc'); + $this->collGroupResources = new PropelObjectCollection(); + $this->collGroupResources->setModel('GroupResource'); } /** - * Gets an array of GroupDesc objects which contain a foreign key that references this object. + * Gets an array of GroupResource objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1467,98 +1685,98 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupDesc[] List of GroupDesc objects + * @return PropelObjectCollection|GroupResource[] List of GroupResource objects * @throws PropelException */ - public function getGroupDescs($criteria = null, PropelPDO $con = null) + public function getGroupResources($criteria = null, PropelPDO $con = null) { - $partial = $this->collGroupDescsPartial && !$this->isNew(); - if (null === $this->collGroupDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupDescs) { + $partial = $this->collGroupResourcesPartial && !$this->isNew(); + if (null === $this->collGroupResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collGroupResources) { // return empty collection - $this->initGroupDescs(); + $this->initGroupResources(); } else { - $collGroupDescs = GroupDescQuery::create(null, $criteria) + $collGroupResources = GroupResourceQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collGroupDescsPartial && count($collGroupDescs)) { - $this->initGroupDescs(false); + if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { + $this->initGroupResources(false); - foreach($collGroupDescs as $obj) { - if (false == $this->collGroupDescs->contains($obj)) { - $this->collGroupDescs->append($obj); + foreach($collGroupResources as $obj) { + if (false == $this->collGroupResources->contains($obj)) { + $this->collGroupResources->append($obj); } } - $this->collGroupDescsPartial = true; + $this->collGroupResourcesPartial = true; } - return $collGroupDescs; + return $collGroupResources; } - if($partial && $this->collGroupDescs) { - foreach($this->collGroupDescs as $obj) { + if($partial && $this->collGroupResources) { + foreach($this->collGroupResources as $obj) { if($obj->isNew()) { - $collGroupDescs[] = $obj; + $collGroupResources[] = $obj; } } } - $this->collGroupDescs = $collGroupDescs; - $this->collGroupDescsPartial = false; + $this->collGroupResources = $collGroupResources; + $this->collGroupResourcesPartial = false; } } - return $this->collGroupDescs; + return $this->collGroupResources; } /** - * Sets a collection of GroupDesc objects related by a one-to-many relationship + * Sets a collection of GroupResource objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param PropelCollection $groupDescs A Propel collection. + * @param PropelCollection $groupResources A Propel collection. * @param PropelPDO $con Optional connection object */ - public function setGroupDescs(PropelCollection $groupDescs, PropelPDO $con = null) + public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) { - $this->groupDescsScheduledForDeletion = $this->getGroupDescs(new Criteria(), $con)->diff($groupDescs); + $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - foreach ($this->groupDescsScheduledForDeletion as $groupDescRemoved) { - $groupDescRemoved->setGroup(null); + foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) { + $groupResourceRemoved->setGroup(null); } - $this->collGroupDescs = null; - foreach ($groupDescs as $groupDesc) { - $this->addGroupDesc($groupDesc); + $this->collGroupResources = null; + foreach ($groupResources as $groupResource) { + $this->addGroupResource($groupResource); } - $this->collGroupDescs = $groupDescs; - $this->collGroupDescsPartial = false; + $this->collGroupResources = $groupResources; + $this->collGroupResourcesPartial = false; } /** - * Returns the number of related GroupDesc objects. + * Returns the number of related GroupResource objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con - * @return int Count of related GroupDesc objects. + * @return int Count of related GroupResource objects. * @throws PropelException */ - public function countGroupDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { - $partial = $this->collGroupDescsPartial && !$this->isNew(); - if (null === $this->collGroupDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupDescs) { + $partial = $this->collGroupResourcesPartial && !$this->isNew(); + if (null === $this->collGroupResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collGroupResources) { return 0; } else { if($partial && !$criteria) { - return count($this->getGroupDescs()); + return count($this->getGroupResources()); } - $query = GroupDescQuery::create(null, $criteria); + $query = GroupResourceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1568,55 +1786,80 @@ abstract class BaseGroup extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collGroupDescs); + return count($this->collGroupResources); } } /** - * Method called to associate a GroupDesc object to this object - * through the GroupDesc foreign key attribute. + * Method called to associate a GroupResource object to this object + * through the GroupResource foreign key attribute. * - * @param GroupDesc $l GroupDesc + * @param GroupResource $l GroupResource * @return Group The current object (for fluent API support) */ - public function addGroupDesc(GroupDesc $l) + public function addGroupResource(GroupResource $l) { - if ($this->collGroupDescs === null) { - $this->initGroupDescs(); - $this->collGroupDescsPartial = true; + if ($this->collGroupResources === null) { + $this->initGroupResources(); + $this->collGroupResourcesPartial = true; } - if (!$this->collGroupDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddGroupDesc($l); + if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddGroupResource($l); } return $this; } /** - * @param GroupDesc $groupDesc The groupDesc object to add. + * @param GroupResource $groupResource The groupResource object to add. */ - protected function doAddGroupDesc($groupDesc) + protected function doAddGroupResource($groupResource) { - $this->collGroupDescs[]= $groupDesc; - $groupDesc->setGroup($this); + $this->collGroupResources[]= $groupResource; + $groupResource->setGroup($this); } /** - * @param GroupDesc $groupDesc The groupDesc object to remove. + * @param GroupResource $groupResource The groupResource object to remove. */ - public function removeGroupDesc($groupDesc) + public function removeGroupResource($groupResource) { - if ($this->getGroupDescs()->contains($groupDesc)) { - $this->collGroupDescs->remove($this->collGroupDescs->search($groupDesc)); - if (null === $this->groupDescsScheduledForDeletion) { - $this->groupDescsScheduledForDeletion = clone $this->collGroupDescs; - $this->groupDescsScheduledForDeletion->clear(); + if ($this->getGroupResources()->contains($groupResource)) { + $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); + if (null === $this->groupResourcesScheduledForDeletion) { + $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; + $this->groupResourcesScheduledForDeletion->clear(); } - $this->groupDescsScheduledForDeletion[]= $groupDesc; - $groupDesc->setGroup(null); + $this->groupResourcesScheduledForDeletion[]= $groupResource; + $groupResource->setGroup(null); } } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Group is new, it will return + * an empty collection; or if this Group has previously + * been saved, it will retrieve related GroupResources from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Group. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|GroupResource[] List of GroupResource objects + */ + public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = GroupResourceQuery::create(null, $criteria); + $query->joinWith('Resource', $join_behavior); + + return $this->getGroupResources($query, $con); + } + /** * Clears out the collGroupModules collection * @@ -1849,238 +2092,6 @@ abstract class BaseGroup extends BaseObject implements Persistent return $this->getGroupModules($query, $con); } - /** - * Clears out the collGroupResources collection - * - * 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 - * @see addGroupResources() - */ - public function clearGroupResources() - { - $this->collGroupResources = null; // important to set this to null since that means it is uninitialized - $this->collGroupResourcesPartial = null; - } - - /** - * reset is the collGroupResources collection loaded partially - * - * @return void - */ - public function resetPartialGroupResources($v = true) - { - $this->collGroupResourcesPartial = $v; - } - - /** - * Initializes the collGroupResources collection. - * - * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupResources($overrideExisting = true) - { - if (null !== $this->collGroupResources && !$overrideExisting) { - return; - } - $this->collGroupResources = new PropelObjectCollection(); - $this->collGroupResources->setModel('GroupResource'); - } - - /** - * Gets an array of GroupResource objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - * @throws PropelException - */ - public function getGroupResources($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - // return empty collection - $this->initGroupResources(); - } else { - $collGroupResources = GroupResourceQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); - - foreach($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); - } - } - - $this->collGroupResourcesPartial = true; - } - - return $collGroupResources; - } - - if($partial && $this->collGroupResources) { - foreach($this->collGroupResources as $obj) { - if($obj->isNew()) { - $collGroupResources[] = $obj; - } - } - } - - $this->collGroupResources = $collGroupResources; - $this->collGroupResourcesPartial = false; - } - } - - return $this->collGroupResources; - } - - /** - * Sets a collection of GroupResource objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $groupResources A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) - { - $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - - foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) { - $groupResourceRemoved->setGroup(null); - } - - $this->collGroupResources = null; - foreach ($groupResources as $groupResource) { - $this->addGroupResource($groupResource); - } - - $this->collGroupResources = $groupResources; - $this->collGroupResourcesPartial = false; - } - - /** - * Returns the number of related GroupResource objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupResource objects. - * @throws PropelException - */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a GroupResource object to this object - * through the GroupResource foreign key attribute. - * - * @param GroupResource $l GroupResource - * @return Group The current object (for fluent API support) - */ - public function addGroupResource(GroupResource $l) - { - if ($this->collGroupResources === null) { - $this->initGroupResources(); - $this->collGroupResourcesPartial = true; - } - if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddGroupResource($l); - } - - return $this; - } - - /** - * @param GroupResource $groupResource The groupResource object to add. - */ - protected function doAddGroupResource($groupResource) - { - $this->collGroupResources[]= $groupResource; - $groupResource->setGroup($this); - } - - /** - * @param GroupResource $groupResource The groupResource object to remove. - */ - public function removeGroupResource($groupResource) - { - if ($this->getGroupResources()->contains($groupResource)) { - $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); - if (null === $this->groupResourcesScheduledForDeletion) { - $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; - $this->groupResourcesScheduledForDeletion->clear(); - } - $this->groupResourcesScheduledForDeletion[]= $groupResource; - $groupResource->setGroup(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related GroupResources from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - */ - public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = GroupResourceQuery::create(null, $criteria); - $query->joinWith('Resource', $join_behavior); - - return $this->getGroupResources($query, $con); - } - /** * Clears the current object and sets all attributes to their default values */ @@ -2110,18 +2121,13 @@ abstract class BaseGroup extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collAdminGroups) { - foreach ($this->collAdminGroups as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collGroupDescs) { foreach ($this->collGroupDescs as $o) { $o->clearAllReferences($deep); } } - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { + if ($this->collAdminGroups) { + foreach ($this->collAdminGroups as $o) { $o->clearAllReferences($deep); } } @@ -2130,24 +2136,29 @@ abstract class BaseGroup extends BaseObject implements Persistent $o->clearAllReferences($deep); } } + if ($this->collGroupModules) { + foreach ($this->collGroupModules as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collAdminGroups instanceof PropelCollection) { - $this->collAdminGroups->clearIterator(); - } - $this->collAdminGroups = null; if ($this->collGroupDescs instanceof PropelCollection) { $this->collGroupDescs->clearIterator(); } $this->collGroupDescs = null; - if ($this->collGroupModules instanceof PropelCollection) { - $this->collGroupModules->clearIterator(); + if ($this->collAdminGroups instanceof PropelCollection) { + $this->collAdminGroups->clearIterator(); } - $this->collGroupModules = null; + $this->collAdminGroups = null; if ($this->collGroupResources instanceof PropelCollection) { $this->collGroupResources->clearIterator(); } $this->collGroupResources = null; + if ($this->collGroupModules instanceof PropelCollection) { + $this->collGroupModules->clearIterator(); + } + $this->collGroupModules = null; } /** @@ -2170,4 +2181,18 @@ abstract class BaseGroup extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Group The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseGroupDesc.php b/core/lib/Thelia/Model/om/BaseGroupDesc.php index 70c7ebc38..e59ad6f58 100644 --- a/core/lib/Thelia/Model/om/BaseGroupDesc.php +++ b/core/lib/Thelia/Model/om/BaseGroupDesc.php @@ -610,8 +610,19 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1306,4 +1317,18 @@ abstract class BaseGroupDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return GroupDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseGroupDescQuery.php b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php index 7976f5572..72dae3934 100644 --- a/core/lib/Thelia/Model/om/BaseGroupDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseGroupDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(GroupDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(GroupDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(GroupDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return GroupDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(GroupDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseGroupModule.php b/core/lib/Thelia/Model/om/BaseGroupModule.php index ee1e968de..5325dc01b 100644 --- a/core/lib/Thelia/Model/om/BaseGroupModule.php +++ b/core/lib/Thelia/Model/om/BaseGroupModule.php @@ -575,8 +575,19 @@ abstract class BaseGroupModule extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupModulePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupModulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupModulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseGroupModule extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return GroupModule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupModulePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php index d43848e11..3d668f6d0 100644 --- a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php @@ -651,4 +651,69 @@ abstract class BaseGroupModuleQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(GroupModulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupModulePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupModulePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(GroupModulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(GroupModulePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return GroupModuleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(GroupModulePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseGroupPeer.php b/core/lib/Thelia/Model/om/BaseGroupPeer.php index ce32ce038..e566bd6e3 100644 --- a/core/lib/Thelia/Model/om/BaseGroupPeer.php +++ b/core/lib/Thelia/Model/om/BaseGroupPeer.php @@ -381,18 +381,18 @@ abstract class BaseGroupPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in AdminGroupPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AdminGroupPeer::clearInstancePool(); // Invalidate objects in GroupDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupDescPeer::clearInstancePool(); - // Invalidate objects in GroupModulePeer instance pool, + // Invalidate objects in AdminGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupModulePeer::clearInstancePool(); + AdminGroupPeer::clearInstancePool(); // Invalidate objects in GroupResourcePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupResourcePeer::clearInstancePool(); + // Invalidate objects in GroupModulePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + GroupModulePeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/om/BaseGroupQuery.php index a6f5c29ad..9fde4c213 100644 --- a/core/lib/Thelia/Model/om/BaseGroupQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupQuery.php @@ -39,22 +39,22 @@ use Thelia\Model\GroupResource; * @method GroupQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method GroupQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method GroupQuery leftJoinAdminGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the AdminGroup relation - * @method GroupQuery rightJoinAdminGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AdminGroup relation - * @method GroupQuery innerJoinAdminGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the AdminGroup relation - * * @method GroupQuery leftJoinGroupDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupDesc relation * @method GroupQuery rightJoinGroupDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupDesc relation * @method GroupQuery innerJoinGroupDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupDesc relation * - * @method GroupQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation - * @method GroupQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation - * @method GroupQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation + * @method GroupQuery leftJoinAdminGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the AdminGroup relation + * @method GroupQuery rightJoinAdminGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AdminGroup relation + * @method GroupQuery innerJoinAdminGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the AdminGroup relation * * @method GroupQuery leftJoinGroupResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupResource relation * @method GroupQuery rightJoinGroupResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupResource relation * @method GroupQuery innerJoinGroupResource($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupResource relation * + * @method GroupQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation + * @method GroupQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation + * @method GroupQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation + * * @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 * @@ -387,80 +387,6 @@ abstract class BaseGroupQuery extends ModelCriteria return $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related AdminGroup object - * - * @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. - */ - public function filterByAdminGroup($adminGroup, $comparison = null) - { - if ($adminGroup instanceof AdminGroup) { - return $this - ->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison); - } elseif ($adminGroup instanceof PropelObjectCollection) { - return $this - ->useAdminGroupQuery() - ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AdminGroup relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AdminGroup'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AdminGroup'); - } - - return $this; - } - - /** - * Use the AdminGroup relation AdminGroup object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query - */ - public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinAdminGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); - } - /** * Filter the query by a related GroupDesc object * @@ -536,41 +462,41 @@ abstract class BaseGroupQuery extends ModelCriteria } /** - * Filter the query by a related GroupModule object + * Filter the query by a related AdminGroup object * - * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter + * @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. */ - public function filterByGroupModule($groupModule, $comparison = null) + public function filterByAdminGroup($adminGroup, $comparison = null) { - if ($groupModule instanceof GroupModule) { + if ($adminGroup instanceof AdminGroup) { return $this - ->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { + ->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison); + } elseif ($adminGroup instanceof PropelObjectCollection) { return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) + ->useAdminGroupQuery() + ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); + throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); } } /** - * Adds a JOIN clause to the query using the GroupModule relation + * Adds a JOIN clause to the query using the AdminGroup relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return GroupQuery The current query, for fluid interface */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinAdminGroup($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); + $relationMap = $tableMap->getRelation('AdminGroup'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -585,14 +511,14 @@ abstract class BaseGroupQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'GroupModule'); + $this->addJoinObject($join, 'AdminGroup'); } return $this; } /** - * Use the GroupModule relation GroupModule object + * Use the AdminGroup relation AdminGroup object * * @see useQuery() * @@ -600,13 +526,13 @@ abstract class BaseGroupQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); + ->joinAdminGroup($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); } /** @@ -683,6 +609,80 @@ abstract class BaseGroupQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); } + /** + * Filter the query by a related GroupModule object + * + * @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. + */ + public function filterByGroupModule($groupModule, $comparison = null) + { + if ($groupModule instanceof GroupModule) { + return $this + ->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison); + } elseif ($groupModule instanceof PropelObjectCollection) { + return $this + ->useGroupModuleQuery() + ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the GroupModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return GroupQuery The current query, for fluid interface + */ + public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('GroupModule'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'GroupModule'); + } + + return $this; + } + + /** + * Use the GroupModule relation GroupModule object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query + */ + public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinGroupModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); + } + /** * Exclude object from result * @@ -699,4 +699,69 @@ abstract class BaseGroupQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return GroupQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(GroupPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return GroupQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return GroupQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return GroupQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(GroupPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return GroupQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(GroupPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return GroupQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(GroupPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseGroupResource.php b/core/lib/Thelia/Model/om/BaseGroupResource.php index 19e6b6d32..8dc1b3f46 100644 --- a/core/lib/Thelia/Model/om/BaseGroupResource.php +++ b/core/lib/Thelia/Model/om/BaseGroupResource.php @@ -619,8 +619,19 @@ abstract class BaseGroupResource extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupResourcePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1378,4 +1389,18 @@ abstract class BaseGroupResource extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return GroupResource The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupResourcePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php index da6d5aa02..8c615c227 100644 --- a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php +++ b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php @@ -696,4 +696,69 @@ abstract class BaseGroupResourceQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupResourcePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupResourcePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(GroupResourcePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return GroupResourceQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(GroupResourcePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/om/BaseImage.php index 83f575469..42a6e8378 100644 --- a/core/lib/Thelia/Model/om/BaseImage.php +++ b/core/lib/Thelia/Model/om/BaseImage.php @@ -711,8 +711,19 @@ abstract class BaseImage extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ImagePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ImagePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ImagePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1906,4 +1917,18 @@ abstract class BaseImage extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Image The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ImagePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseImageDesc.php b/core/lib/Thelia/Model/om/BaseImageDesc.php index baf8e28b9..d6db7b517 100644 --- a/core/lib/Thelia/Model/om/BaseImageDesc.php +++ b/core/lib/Thelia/Model/om/BaseImageDesc.php @@ -572,8 +572,19 @@ abstract class BaseImageDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ImageDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ImageDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ImageDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1262,4 +1273,18 @@ abstract class BaseImageDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ImageDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ImageDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseImageDescQuery.php b/core/lib/Thelia/Model/om/BaseImageDescQuery.php index e4aba6205..38c0abc11 100644 --- a/core/lib/Thelia/Model/om/BaseImageDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseImageDescQuery.php @@ -577,4 +577,69 @@ abstract class BaseImageDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ImageDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ImageDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ImageDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ImageDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ImageDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ImageDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ImageDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/om/BaseImageQuery.php index e4e390da2..82c705938 100644 --- a/core/lib/Thelia/Model/om/BaseImageQuery.php +++ b/core/lib/Thelia/Model/om/BaseImageQuery.php @@ -1019,4 +1019,69 @@ abstract class BaseImageQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ImagePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ImagePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ImagePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ImagePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ImagePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ImagePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseLang.php b/core/lib/Thelia/Model/om/BaseLang.php index b3d1f23fb..fc1a042c7 100644 --- a/core/lib/Thelia/Model/om/BaseLang.php +++ b/core/lib/Thelia/Model/om/BaseLang.php @@ -70,10 +70,10 @@ abstract class BaseLang extends BaseObject implements Persistent protected $url; /** - * The value for the default_utility field. + * The value for the by_default field. * @var int */ - protected $default_utility; + protected $by_default; /** * The value for the created_at field. @@ -142,13 +142,13 @@ abstract class BaseLang extends BaseObject implements Persistent } /** - * Get the [default_utility] column value. + * Get the [by_default] column value. * * @return int */ - public function getDefaultUtility() + public function getByDefault() { - return $this->default_utility; + return $this->by_default; } /** @@ -310,25 +310,25 @@ abstract class BaseLang extends BaseObject implements Persistent } // setUrl() /** - * Set the value of [default_utility] column. + * Set the value of [by_default] column. * * @param int $v new value * @return Lang The current object (for fluent API support) */ - public function setDefaultUtility($v) + public function setByDefault($v) { if ($v !== null) { $v = (int) $v; } - if ($this->default_utility !== $v) { - $this->default_utility = $v; - $this->modifiedColumns[] = LangPeer::DEFAULT_UTILITY; + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = LangPeer::BY_DEFAULT; } return $this; - } // setDefaultUtility() + } // setByDefault() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -412,7 +412,7 @@ abstract class BaseLang extends BaseObject implements Persistent $this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->url = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->default_utility = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->by_default = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->resetModified(); @@ -557,8 +557,19 @@ abstract class BaseLang extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(LangPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(LangPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(LangPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -647,8 +658,8 @@ abstract class BaseLang extends BaseObject implements Persistent if ($this->isColumnModified(LangPeer::URL)) { $modifiedColumns[':p' . $index++] = '`URL`'; } - if ($this->isColumnModified(LangPeer::DEFAULT_UTILITY)) { - $modifiedColumns[':p' . $index++] = '`DEFAULT_UTILITY`'; + if ($this->isColumnModified(LangPeer::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = '`BY_DEFAULT`'; } if ($this->isColumnModified(LangPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; @@ -679,8 +690,8 @@ abstract class BaseLang extends BaseObject implements Persistent case '`URL`': $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); break; - case '`DEFAULT_UTILITY`': - $stmt->bindValue($identifier, $this->default_utility, PDO::PARAM_INT); + case '`BY_DEFAULT`': + $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; case '`CREATED_AT`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); @@ -835,7 +846,7 @@ abstract class BaseLang extends BaseObject implements Persistent return $this->getUrl(); break; case 4: - return $this->getDefaultUtility(); + return $this->getByDefault(); break; case 5: return $this->getCreatedAt(); @@ -875,7 +886,7 @@ abstract class BaseLang extends BaseObject implements Persistent $keys[1] => $this->getTitle(), $keys[2] => $this->getCode(), $keys[3] => $this->getUrl(), - $keys[4] => $this->getDefaultUtility(), + $keys[4] => $this->getByDefault(), $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); @@ -925,7 +936,7 @@ abstract class BaseLang extends BaseObject implements Persistent $this->setUrl($value); break; case 4: - $this->setDefaultUtility($value); + $this->setByDefault($value); break; case 5: $this->setCreatedAt($value); @@ -961,7 +972,7 @@ abstract class BaseLang extends BaseObject implements Persistent if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setUrl($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDefaultUtility($arr[$keys[4]]); + if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } @@ -979,7 +990,7 @@ abstract class BaseLang extends BaseObject implements Persistent if ($this->isColumnModified(LangPeer::TITLE)) $criteria->add(LangPeer::TITLE, $this->title); if ($this->isColumnModified(LangPeer::CODE)) $criteria->add(LangPeer::CODE, $this->code); if ($this->isColumnModified(LangPeer::URL)) $criteria->add(LangPeer::URL, $this->url); - if ($this->isColumnModified(LangPeer::DEFAULT_UTILITY)) $criteria->add(LangPeer::DEFAULT_UTILITY, $this->default_utility); + if ($this->isColumnModified(LangPeer::BY_DEFAULT)) $criteria->add(LangPeer::BY_DEFAULT, $this->by_default); if ($this->isColumnModified(LangPeer::CREATED_AT)) $criteria->add(LangPeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(LangPeer::UPDATED_AT)) $criteria->add(LangPeer::UPDATED_AT, $this->updated_at); @@ -1048,7 +1059,7 @@ abstract class BaseLang extends BaseObject implements Persistent $copyObj->setTitle($this->getTitle()); $copyObj->setCode($this->getCode()); $copyObj->setUrl($this->getUrl()); - $copyObj->setDefaultUtility($this->getDefaultUtility()); + $copyObj->setByDefault($this->getByDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1106,7 +1117,7 @@ abstract class BaseLang extends BaseObject implements Persistent $this->title = null; $this->code = null; $this->url = null; - $this->default_utility = null; + $this->by_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1153,4 +1164,18 @@ abstract class BaseLang extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Lang The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = LangPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseLangPeer.php b/core/lib/Thelia/Model/om/BaseLangPeer.php index 4282c0a19..b8cc515cd 100644 --- a/core/lib/Thelia/Model/om/BaseLangPeer.php +++ b/core/lib/Thelia/Model/om/BaseLangPeer.php @@ -56,8 +56,8 @@ abstract class BaseLangPeer /** the column name for the URL field */ const URL = 'lang.URL'; - /** the column name for the DEFAULT_UTILITY field */ - const DEFAULT_UTILITY = 'lang.DEFAULT_UTILITY'; + /** 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'; @@ -84,11 +84,11 @@ abstract class BaseLangPeer * e.g. LangPeer::$fieldNames[LangPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Code', 'Url', 'DefaultUtility', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'code', 'url', 'defaultUtility', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (LangPeer::ID, LangPeer::TITLE, LangPeer::CODE, LangPeer::URL, LangPeer::DEFAULT_UTILITY, LangPeer::CREATED_AT, LangPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CODE', 'URL', 'DEFAULT_UTILITY', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'code', 'url', 'default_utility', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Code', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'code', 'url', 'byDefault', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (LangPeer::ID, LangPeer::TITLE, LangPeer::CODE, LangPeer::URL, LangPeer::BY_DEFAULT, LangPeer::CREATED_AT, LangPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CODE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'code', 'url', 'by_default', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -99,11 +99,11 @@ abstract class BaseLangPeer * e.g. LangPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Code' => 2, 'Url' => 3, 'DefaultUtility' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'defaultUtility' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (LangPeer::ID => 0, LangPeer::TITLE => 1, LangPeer::CODE => 2, LangPeer::URL => 3, LangPeer::DEFAULT_UTILITY => 4, LangPeer::CREATED_AT => 5, LangPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'URL' => 3, 'DEFAULT_UTILITY' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'default_utility' => 4, 'created_at' => 5, 'updated_at' => 6, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Code' => 2, 'Url' => 3, 'ByDefault' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'byDefault' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + BasePeer::TYPE_COLNAME => array (LangPeer::ID => 0, LangPeer::TITLE => 1, LangPeer::CODE => 2, LangPeer::URL => 3, LangPeer::BY_DEFAULT => 4, LangPeer::CREATED_AT => 5, LangPeer::UPDATED_AT => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'URL' => 3, 'BY_DEFAULT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'url' => 3, 'by_default' => 4, 'created_at' => 5, 'updated_at' => 6, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -182,7 +182,7 @@ abstract class BaseLangPeer $criteria->addSelectColumn(LangPeer::TITLE); $criteria->addSelectColumn(LangPeer::CODE); $criteria->addSelectColumn(LangPeer::URL); - $criteria->addSelectColumn(LangPeer::DEFAULT_UTILITY); + $criteria->addSelectColumn(LangPeer::BY_DEFAULT); $criteria->addSelectColumn(LangPeer::CREATED_AT); $criteria->addSelectColumn(LangPeer::UPDATED_AT); } else { @@ -190,7 +190,7 @@ abstract class BaseLangPeer $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.CODE'); $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.DEFAULT_UTILITY'); + $criteria->addSelectColumn($alias . '.BY_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/om/BaseLangQuery.php index 0e084a87d..0ca82516d 100644 --- a/core/lib/Thelia/Model/om/BaseLangQuery.php +++ b/core/lib/Thelia/Model/om/BaseLangQuery.php @@ -23,7 +23,7 @@ use Thelia\Model\LangQuery; * @method LangQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method LangQuery orderByCode($order = Criteria::ASC) Order by the code column * @method LangQuery orderByUrl($order = Criteria::ASC) Order by the url column - * @method LangQuery orderByDefaultUtility($order = Criteria::ASC) Order by the default_utility column + * @method LangQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column * @method LangQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method LangQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -31,7 +31,7 @@ use Thelia\Model\LangQuery; * @method LangQuery groupByTitle() Group by the title column * @method LangQuery groupByCode() Group by the code column * @method LangQuery groupByUrl() Group by the url column - * @method LangQuery groupByDefaultUtility() Group by the default_utility column + * @method LangQuery groupByByDefault() Group by the by_default column * @method LangQuery groupByCreatedAt() Group by the created_at column * @method LangQuery groupByUpdatedAt() Group by the updated_at column * @@ -46,7 +46,7 @@ use Thelia\Model\LangQuery; * @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 findOneByUrl(string $url) Return the first Lang filtered by the url column - * @method Lang findOneByDefaultUtility(int $default_utility) Return the first Lang filtered by the default_utility column + * @method Lang findOneByByDefault(int $by_default) Return the first Lang filtered by the by_default column * @method Lang findOneByCreatedAt(string $created_at) Return the first Lang filtered by the created_at column * @method Lang findOneByUpdatedAt(string $updated_at) Return the first Lang filtered by the updated_at column * @@ -54,7 +54,7 @@ use Thelia\Model\LangQuery; * @method array findByTitle(string $title) Return Lang objects filtered by the title column * @method array findByCode(string $code) Return Lang objects filtered by the code column * @method array findByUrl(string $url) Return Lang objects filtered by the url column - * @method array findByDefaultUtility(int $default_utility) Return Lang objects filtered by the default_utility column + * @method array findByByDefault(int $by_default) Return Lang objects filtered by the by_default column * @method array findByCreatedAt(string $created_at) Return Lang objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return Lang objects filtered by the updated_at column * @@ -146,7 +146,7 @@ abstract class BaseLangQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TITLE`, `CODE`, `URL`, `DEFAULT_UTILITY`, `CREATED_AT`, `UPDATED_AT` FROM `lang` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `TITLE`, `CODE`, `URL`, `BY_DEFAULT`, `CREATED_AT`, `UPDATED_AT` FROM `lang` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -350,16 +350,16 @@ abstract class BaseLangQuery extends ModelCriteria } /** - * Filter the query on the default_utility column + * Filter the query on the by_default column * * Example usage: * - * $query->filterByDefaultUtility(1234); // WHERE default_utility = 1234 - * $query->filterByDefaultUtility(array(12, 34)); // WHERE default_utility IN (12, 34) - * $query->filterByDefaultUtility(array('min' => 12)); // WHERE default_utility > 12 + * $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 * * - * @param mixed $defaultUtility The value to use as filter. + * @param mixed $byDefault The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -367,16 +367,16 @@ abstract class BaseLangQuery extends ModelCriteria * * @return LangQuery The current query, for fluid interface */ - public function filterByDefaultUtility($defaultUtility = null, $comparison = null) + public function filterByByDefault($byDefault = null, $comparison = null) { - if (is_array($defaultUtility)) { + if (is_array($byDefault)) { $useMinMax = false; - if (isset($defaultUtility['min'])) { - $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility['min'], Criteria::GREATER_EQUAL); + if (isset($byDefault['min'])) { + $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($defaultUtility['max'])) { - $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility['max'], Criteria::LESS_EQUAL); + if (isset($byDefault['max'])) { + $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -387,7 +387,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::DEFAULT_UTILITY, $defaultUtility, $comparison); + return $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault, $comparison); } /** @@ -492,4 +492,69 @@ abstract class BaseLangQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return LangQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(LangPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return LangQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(LangPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return LangQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(LangPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return LangQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(LangPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return LangQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(LangPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return LangQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(LangPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php index 6f3fb5622..e0119d241 100644 --- a/core/lib/Thelia/Model/om/BaseMessage.php +++ b/core/lib/Thelia/Model/om/BaseMessage.php @@ -62,10 +62,10 @@ abstract class BaseMessage extends BaseObject implements Persistent protected $code; /** - * The value for the secure field. + * The value for the secured field. * @var int */ - protected $secure; + protected $secured; /** * The value for the created_at field. @@ -126,13 +126,13 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * Get the [secure] column value. + * Get the [secured] column value. * * @return int */ - public function getSecure() + public function getSecured() { - return $this->secure; + return $this->secured; } /** @@ -252,25 +252,25 @@ abstract class BaseMessage extends BaseObject implements Persistent } // setCode() /** - * Set the value of [secure] column. + * Set the value of [secured] column. * * @param int $v new value * @return Message The current object (for fluent API support) */ - public function setSecure($v) + public function setSecured($v) { if ($v !== null) { $v = (int) $v; } - if ($this->secure !== $v) { - $this->secure = $v; - $this->modifiedColumns[] = MessagePeer::SECURE; + if ($this->secured !== $v) { + $this->secured = $v; + $this->modifiedColumns[] = MessagePeer::SECURED; } return $this; - } // setSecure() + } // setSecured() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -352,7 +352,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->secure = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->secured = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->resetModified(); @@ -499,8 +499,19 @@ abstract class BaseMessage extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(MessagePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(MessagePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(MessagePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -600,8 +611,8 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->isColumnModified(MessagePeer::CODE)) { $modifiedColumns[':p' . $index++] = '`CODE`'; } - if ($this->isColumnModified(MessagePeer::SECURE)) { - $modifiedColumns[':p' . $index++] = '`SECURE`'; + if ($this->isColumnModified(MessagePeer::SECURED)) { + $modifiedColumns[':p' . $index++] = '`SECURED`'; } if ($this->isColumnModified(MessagePeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; @@ -626,8 +637,8 @@ abstract class BaseMessage extends BaseObject implements Persistent case '`CODE`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`SECURE`': - $stmt->bindValue($identifier, $this->secure, PDO::PARAM_INT); + case '`SECURED`': + $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; case '`CREATED_AT`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); @@ -784,7 +795,7 @@ abstract class BaseMessage extends BaseObject implements Persistent return $this->getCode(); break; case 2: - return $this->getSecure(); + return $this->getSecured(); break; case 3: return $this->getCreatedAt(); @@ -823,7 +834,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), - $keys[2] => $this->getSecure(), + $keys[2] => $this->getSecured(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -872,7 +883,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $this->setCode($value); break; case 2: - $this->setSecure($value); + $this->setSecured($value); break; case 3: $this->setCreatedAt($value); @@ -906,7 +917,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setSecure($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setSecured($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -922,7 +933,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->isColumnModified(MessagePeer::ID)) $criteria->add(MessagePeer::ID, $this->id); if ($this->isColumnModified(MessagePeer::CODE)) $criteria->add(MessagePeer::CODE, $this->code); - if ($this->isColumnModified(MessagePeer::SECURE)) $criteria->add(MessagePeer::SECURE, $this->secure); + if ($this->isColumnModified(MessagePeer::SECURED)) $criteria->add(MessagePeer::SECURED, $this->secured); if ($this->isColumnModified(MessagePeer::CREATED_AT)) $criteria->add(MessagePeer::CREATED_AT, $this->created_at); if ($this->isColumnModified(MessagePeer::UPDATED_AT)) $criteria->add(MessagePeer::UPDATED_AT, $this->updated_at); @@ -989,7 +1000,7 @@ abstract class BaseMessage extends BaseObject implements Persistent public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCode($this->getCode()); - $copyObj->setSecure($this->getSecure()); + $copyObj->setSecured($this->getSecured()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1286,7 +1297,7 @@ abstract class BaseMessage extends BaseObject implements Persistent { $this->id = null; $this->code = null; - $this->secure = null; + $this->secured = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1342,4 +1353,18 @@ abstract class BaseMessage extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Message The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = MessagePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseMessageDesc.php b/core/lib/Thelia/Model/om/BaseMessageDesc.php index 12caa4890..65740e037 100644 --- a/core/lib/Thelia/Model/om/BaseMessageDesc.php +++ b/core/lib/Thelia/Model/om/BaseMessageDesc.php @@ -212,13 +212,40 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent } /** - * Get the [updated_at] column value. + * Get the [optionally formatted] temporal [updated_at] column value. * - * @return string + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. */ - public function getUpdatedAt() + public function getUpdatedAt($format = 'Y-m-d H:i:s') { - return $this->updated_at; + if ($this->updated_at === null) { + return null; + } + + if ($this->updated_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } } /** @@ -375,21 +402,23 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent } // setCreatedAt() /** - * Set the value of [updated_at] column. + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. * - * @param string $v new value + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. * @return MessageDesc The current object (for fluent API support) */ public function setUpdatedAt($v) { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->updated_at !== $v) { - $this->updated_at = $v; - $this->modifiedColumns[] = MessageDescPeer::UPDATED_AT; - } + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = MessageDescPeer::UPDATED_AT; + } + } // if either are not null return $this; @@ -581,8 +610,19 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(MessageDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(MessageDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(MessageDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1288,4 +1328,18 @@ abstract class BaseMessageDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return MessageDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = MessageDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseMessageDescQuery.php b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php index b5d67bb4e..f71b3c23f 100644 --- a/core/lib/Thelia/Model/om/BaseMessageDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseMessageDescQuery.php @@ -480,24 +480,38 @@ abstract class BaseMessageDescQuery extends ModelCriteria * * Example usage: * - * $query->filterByUpdatedAt('fooValue'); // WHERE updated_at = 'fooValue' - * $query->filterByUpdatedAt('%fooValue%'); // WHERE updated_at LIKE '%fooValue%' + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' * * - * @param string $updatedAt The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return MessageDescQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { - if (null === $comparison) { - if (is_array($updatedAt)) { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(MessageDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(MessageDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $updatedAt)) { - $updatedAt = str_replace('*', '%', $updatedAt); - $comparison = Criteria::LIKE; } } @@ -596,4 +610,69 @@ abstract class BaseMessageDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(MessageDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(MessageDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(MessageDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(MessageDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(MessageDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return MessageDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(MessageDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php index 822db1936..39f49d5f7 100644 --- a/core/lib/Thelia/Model/om/BaseMessagePeer.php +++ b/core/lib/Thelia/Model/om/BaseMessagePeer.php @@ -51,8 +51,8 @@ abstract class BaseMessagePeer /** the column name for the CODE field */ const CODE = 'message.CODE'; - /** the column name for the SECURE field */ - const SECURE = 'message.SECURE'; + /** the column name for the SECURED field */ + const SECURED = 'message.SECURED'; /** the column name for the CREATED_AT field */ const CREATED_AT = 'message.CREATED_AT'; @@ -79,11 +79,11 @@ abstract class BaseMessagePeer * e.g. MessagePeer::$fieldNames[MessagePeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Secure', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secure', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (MessagePeer::ID, MessagePeer::CODE, MessagePeer::SECURE, MessagePeer::CREATED_AT, MessagePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secure', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Secured', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'secured', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (MessagePeer::ID, MessagePeer::CODE, MessagePeer::SECURED, MessagePeer::CREATED_AT, MessagePeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'SECURED', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'secured', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); @@ -94,11 +94,11 @@ abstract class BaseMessagePeer * e.g. MessagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secure' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secure' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (MessagePeer::ID => 0, MessagePeer::CODE => 1, MessagePeer::SECURE => 2, MessagePeer::CREATED_AT => 3, MessagePeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secure' => 2, 'created_at' => 3, 'updated_at' => 4, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Secured' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + BasePeer::TYPE_COLNAME => array (MessagePeer::ID => 0, MessagePeer::CODE => 1, MessagePeer::SECURED => 2, MessagePeer::CREATED_AT => 3, MessagePeer::UPDATED_AT => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'secured' => 2, 'created_at' => 3, 'updated_at' => 4, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); @@ -175,13 +175,13 @@ abstract class BaseMessagePeer if (null === $alias) { $criteria->addSelectColumn(MessagePeer::ID); $criteria->addSelectColumn(MessagePeer::CODE); - $criteria->addSelectColumn(MessagePeer::SECURE); + $criteria->addSelectColumn(MessagePeer::SECURED); $criteria->addSelectColumn(MessagePeer::CREATED_AT); $criteria->addSelectColumn(MessagePeer::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.SECURE'); + $criteria->addSelectColumn($alias . '.SECURED'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php index 03221281b..f9d68f71e 100644 --- a/core/lib/Thelia/Model/om/BaseMessageQuery.php +++ b/core/lib/Thelia/Model/om/BaseMessageQuery.php @@ -24,13 +24,13 @@ use Thelia\Model\MessageQuery; * * @method MessageQuery orderById($order = Criteria::ASC) Order by the id column * @method MessageQuery orderByCode($order = Criteria::ASC) Order by the code column - * @method MessageQuery orderBySecure($order = Criteria::ASC) Order by the secure column + * @method MessageQuery orderBySecured($order = Criteria::ASC) Order by the secured column * @method MessageQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method MessageQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method MessageQuery groupById() Group by the id column * @method MessageQuery groupByCode() Group by the code column - * @method MessageQuery groupBySecure() Group by the secure column + * @method MessageQuery groupBySecured() Group by the secured column * @method MessageQuery groupByCreatedAt() Group by the created_at column * @method MessageQuery groupByUpdatedAt() Group by the updated_at column * @@ -47,13 +47,13 @@ use Thelia\Model\MessageQuery; * * @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 findOneBySecure(int $secure) Return the first Message filtered by the secure column + * @method Message findOneBySecured(int $secured) Return the first Message filtered by the secured column * @method Message findOneByCreatedAt(string $created_at) Return the first Message filtered by the created_at column * @method Message findOneByUpdatedAt(string $updated_at) Return the first Message filtered by the updated_at column * * @method array findById(int $id) Return Message objects filtered by the id column * @method array findByCode(string $code) Return Message objects filtered by the code column - * @method array findBySecure(int $secure) Return Message objects filtered by the secure column + * @method array findBySecured(int $secured) Return Message objects filtered by the secured column * @method array findByCreatedAt(string $created_at) Return Message objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return Message objects filtered by the updated_at column * @@ -145,7 +145,7 @@ abstract class BaseMessageQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `CODE`, `SECURE`, `CREATED_AT`, `UPDATED_AT` FROM `message` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `CODE`, `SECURED`, `CREATED_AT`, `UPDATED_AT` FROM `message` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -291,16 +291,16 @@ abstract class BaseMessageQuery extends ModelCriteria } /** - * Filter the query on the secure column + * Filter the query on the secured column * * Example usage: * - * $query->filterBySecure(1234); // WHERE secure = 1234 - * $query->filterBySecure(array(12, 34)); // WHERE secure IN (12, 34) - * $query->filterBySecure(array('min' => 12)); // WHERE secure > 12 + * $query->filterBySecured(1234); // WHERE secured = 1234 + * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34) + * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 * * - * @param mixed $secure The value to use as filter. + * @param mixed $secured The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -308,16 +308,16 @@ abstract class BaseMessageQuery extends ModelCriteria * * @return MessageQuery The current query, for fluid interface */ - public function filterBySecure($secure = null, $comparison = null) + public function filterBySecured($secured = null, $comparison = null) { - if (is_array($secure)) { + if (is_array($secured)) { $useMinMax = false; - if (isset($secure['min'])) { - $this->addUsingAlias(MessagePeer::SECURE, $secure['min'], Criteria::GREATER_EQUAL); + if (isset($secured['min'])) { + $this->addUsingAlias(MessagePeer::SECURED, $secured['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($secure['max'])) { - $this->addUsingAlias(MessagePeer::SECURE, $secure['max'], Criteria::LESS_EQUAL); + if (isset($secured['max'])) { + $this->addUsingAlias(MessagePeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -328,7 +328,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::SECURE, $secure, $comparison); + return $this->addUsingAlias(MessagePeer::SECURED, $secured, $comparison); } /** @@ -507,4 +507,69 @@ abstract class BaseMessageQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return MessageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(MessagePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return MessageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(MessagePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return MessageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(MessagePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return MessageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(MessagePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return MessageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(MessagePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return MessageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(MessagePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseModule.php b/core/lib/Thelia/Model/om/BaseModule.php index 0ba8ad580..fb80a2ef5 100644 --- a/core/lib/Thelia/Model/om/BaseModule.php +++ b/core/lib/Thelia/Model/om/BaseModule.php @@ -64,10 +64,10 @@ abstract class BaseModule extends BaseObject implements Persistent protected $code; /** - * The value for the type field. + * The value for the type field. * @var int */ - protected $type; + protected $ type; /** * The value for the activate field. @@ -93,18 +93,18 @@ abstract class BaseModule extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects. - */ - protected $collGroupModules; - protected $collGroupModulesPartial; - /** * @var PropelObjectCollection|ModuleDesc[] Collection to store aggregation of ModuleDesc objects. */ protected $collModuleDescs; protected $collModuleDescsPartial; + /** + * @var PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects. + */ + protected $collGroupModules; + protected $collGroupModulesPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -123,13 +123,13 @@ abstract class BaseModule extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $groupModulesScheduledForDeletion = null; + protected $moduleDescsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $moduleDescsScheduledForDeletion = null; + protected $groupModulesScheduledForDeletion = null; /** * Get the [id] column value. @@ -152,13 +152,13 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * Get the [type] column value. + * Get the [ type] column value. * * @return int */ - public function getType() + public function get type() { - return $this->type; + return $this-> type; } /** @@ -298,25 +298,25 @@ abstract class BaseModule extends BaseObject implements Persistent } // setCode() /** - * Set the value of [type] column. + * Set the value of [ type] column. * * @param int $v new value * @return Module The current object (for fluent API support) */ - public function setType($v) + public function set type($v) { if ($v !== null) { $v = (int) $v; } - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = ModulePeer::TYPE; + if ($this-> type !== $v) { + $this-> type = $v; + $this->modifiedColumns[] = ModulePeer:: TYPE; } return $this; - } // setType() + } // set type() /** * Set the value of [activate] column. @@ -440,7 +440,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->type = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this-> type = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; $this->activate = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; @@ -515,10 +515,10 @@ abstract class BaseModule extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collGroupModules = null; - $this->collModuleDescs = null; + $this->collGroupModules = null; + } // if (deep) } @@ -591,8 +591,19 @@ abstract class BaseModule extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ModulePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ModulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ModulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -643,6 +654,23 @@ abstract class BaseModule extends BaseObject implements Persistent $this->resetModified(); } + if ($this->moduleDescsScheduledForDeletion !== null) { + if (!$this->moduleDescsScheduledForDeletion->isEmpty()) { + ModuleDescQuery::create() + ->filterByPrimaryKeys($this->moduleDescsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->moduleDescsScheduledForDeletion = null; + } + } + + if ($this->collModuleDescs !== null) { + foreach ($this->collModuleDescs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->groupModulesScheduledForDeletion !== null) { if (!$this->groupModulesScheduledForDeletion->isEmpty()) { foreach ($this->groupModulesScheduledForDeletion as $groupModule) { @@ -661,23 +689,6 @@ abstract class BaseModule extends BaseObject implements Persistent } } - if ($this->moduleDescsScheduledForDeletion !== null) { - if (!$this->moduleDescsScheduledForDeletion->isEmpty()) { - ModuleDescQuery::create() - ->filterByPrimaryKeys($this->moduleDescsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->moduleDescsScheduledForDeletion = null; - } - } - - if ($this->collModuleDescs !== null) { - foreach ($this->collModuleDescs as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - $this->alreadyInSave = false; } @@ -706,8 +717,8 @@ abstract class BaseModule extends BaseObject implements Persistent if ($this->isColumnModified(ModulePeer::CODE)) { $modifiedColumns[':p' . $index++] = '`CODE`'; } - if ($this->isColumnModified(ModulePeer::TYPE)) { - $modifiedColumns[':p' . $index++] = '`TYPE`'; + if ($this->isColumnModified(ModulePeer:: TYPE)) { + $modifiedColumns[':p' . $index++] = '` TYPE`'; } if ($this->isColumnModified(ModulePeer::ACTIVATE)) { $modifiedColumns[':p' . $index++] = '`ACTIVATE`'; @@ -738,8 +749,8 @@ abstract class BaseModule extends BaseObject implements Persistent case '`CODE`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`TYPE`': - $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT); + case '` TYPE`': + $stmt->bindValue($identifier, $this-> type, PDO::PARAM_INT); break; case '`ACTIVATE`': $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); @@ -845,16 +856,16 @@ abstract class BaseModule extends BaseObject implements Persistent } - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { + if ($this->collModuleDescs !== null) { + foreach ($this->collModuleDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collModuleDescs !== null) { - foreach ($this->collModuleDescs as $referrerFK) { + if ($this->collGroupModules !== null) { + foreach ($this->collGroupModules as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -903,7 +914,7 @@ abstract class BaseModule extends BaseObject implements Persistent return $this->getCode(); break; case 2: - return $this->getType(); + return $this->get type(); break; case 3: return $this->getActivate(); @@ -948,19 +959,19 @@ abstract class BaseModule extends BaseObject implements Persistent $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), - $keys[2] => $this->getType(), + $keys[2] => $this->get type(), $keys[3] => $this->getActivate(), $keys[4] => $this->getPosition(), $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collModuleDescs) { $result['ModuleDescs'] = $this->collModuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collGroupModules) { + $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1002,7 +1013,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->setCode($value); break; case 2: - $this->setType($value); + $this->set type($value); break; case 3: $this->setActivate($value); @@ -1042,7 +1053,7 @@ abstract class BaseModule extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->set type($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setActivate($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); @@ -1060,7 +1071,7 @@ abstract class BaseModule extends BaseObject implements Persistent if ($this->isColumnModified(ModulePeer::ID)) $criteria->add(ModulePeer::ID, $this->id); if ($this->isColumnModified(ModulePeer::CODE)) $criteria->add(ModulePeer::CODE, $this->code); - if ($this->isColumnModified(ModulePeer::TYPE)) $criteria->add(ModulePeer::TYPE, $this->type); + if ($this->isColumnModified(ModulePeer:: TYPE)) $criteria->add(ModulePeer:: TYPE, $this-> type); if ($this->isColumnModified(ModulePeer::ACTIVATE)) $criteria->add(ModulePeer::ACTIVATE, $this->activate); if ($this->isColumnModified(ModulePeer::POSITION)) $criteria->add(ModulePeer::POSITION, $this->position); if ($this->isColumnModified(ModulePeer::CREATED_AT)) $criteria->add(ModulePeer::CREATED_AT, $this->created_at); @@ -1129,7 +1140,7 @@ abstract class BaseModule extends BaseObject implements Persistent public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCode($this->getCode()); - $copyObj->setType($this->getType()); + $copyObj->set type($this->get type()); $copyObj->setActivate($this->getActivate()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); @@ -1142,18 +1153,18 @@ abstract class BaseModule extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getGroupModules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); - } - } - foreach ($this->getModuleDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addModuleDesc($relObj->copy($deepCopy)); } } + foreach ($this->getGroupModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addGroupModule($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1215,11 +1226,218 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('ModuleDesc' == $relationName) { + $this->initModuleDescs(); + } if ('GroupModule' == $relationName) { $this->initGroupModules(); } - if ('ModuleDesc' == $relationName) { + } + + /** + * Clears out the collModuleDescs collection + * + * 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 + * @see addModuleDescs() + */ + public function clearModuleDescs() + { + $this->collModuleDescs = null; // important to set this to null since that means it is uninitialized + $this->collModuleDescsPartial = null; + } + + /** + * reset is the collModuleDescs collection loaded partially + * + * @return void + */ + public function resetPartialModuleDescs($v = true) + { + $this->collModuleDescsPartial = $v; + } + + /** + * Initializes the collModuleDescs collection. + * + * By default this just sets the collModuleDescs collection to an empty array (like clearcollModuleDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initModuleDescs($overrideExisting = true) + { + if (null !== $this->collModuleDescs && !$overrideExisting) { + return; + } + $this->collModuleDescs = new PropelObjectCollection(); + $this->collModuleDescs->setModel('ModuleDesc'); + } + + /** + * Gets an array of ModuleDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Module is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ModuleDesc[] List of ModuleDesc objects + * @throws PropelException + */ + public function getModuleDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collModuleDescsPartial && !$this->isNew(); + if (null === $this->collModuleDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleDescs) { + // return empty collection + $this->initModuleDescs(); + } else { + $collModuleDescs = ModuleDescQuery::create(null, $criteria) + ->filterByModule($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collModuleDescsPartial && count($collModuleDescs)) { + $this->initModuleDescs(false); + + foreach($collModuleDescs as $obj) { + if (false == $this->collModuleDescs->contains($obj)) { + $this->collModuleDescs->append($obj); + } + } + + $this->collModuleDescsPartial = true; + } + + return $collModuleDescs; + } + + if($partial && $this->collModuleDescs) { + foreach($this->collModuleDescs as $obj) { + if($obj->isNew()) { + $collModuleDescs[] = $obj; + } + } + } + + $this->collModuleDescs = $collModuleDescs; + $this->collModuleDescsPartial = false; + } + } + + return $this->collModuleDescs; + } + + /** + * Sets a collection of ModuleDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $moduleDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setModuleDescs(PropelCollection $moduleDescs, PropelPDO $con = null) + { + $this->moduleDescsScheduledForDeletion = $this->getModuleDescs(new Criteria(), $con)->diff($moduleDescs); + + foreach ($this->moduleDescsScheduledForDeletion as $moduleDescRemoved) { + $moduleDescRemoved->setModule(null); + } + + $this->collModuleDescs = null; + foreach ($moduleDescs as $moduleDesc) { + $this->addModuleDesc($moduleDesc); + } + + $this->collModuleDescs = $moduleDescs; + $this->collModuleDescsPartial = false; + } + + /** + * Returns the number of related ModuleDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ModuleDesc objects. + * @throws PropelException + */ + public function countModuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collModuleDescsPartial && !$this->isNew(); + if (null === $this->collModuleDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collModuleDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getModuleDescs()); + } + $query = ModuleDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); + } + } else { + return count($this->collModuleDescs); + } + } + + /** + * Method called to associate a ModuleDesc object to this object + * through the ModuleDesc foreign key attribute. + * + * @param ModuleDesc $l ModuleDesc + * @return Module The current object (for fluent API support) + */ + public function addModuleDesc(ModuleDesc $l) + { + if ($this->collModuleDescs === null) { $this->initModuleDescs(); + $this->collModuleDescsPartial = true; + } + if (!$this->collModuleDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddModuleDesc($l); + } + + return $this; + } + + /** + * @param ModuleDesc $moduleDesc The moduleDesc object to add. + */ + protected function doAddModuleDesc($moduleDesc) + { + $this->collModuleDescs[]= $moduleDesc; + $moduleDesc->setModule($this); + } + + /** + * @param ModuleDesc $moduleDesc The moduleDesc object to remove. + */ + public function removeModuleDesc($moduleDesc) + { + if ($this->getModuleDescs()->contains($moduleDesc)) { + $this->collModuleDescs->remove($this->collModuleDescs->search($moduleDesc)); + if (null === $this->moduleDescsScheduledForDeletion) { + $this->moduleDescsScheduledForDeletion = clone $this->collModuleDescs; + $this->moduleDescsScheduledForDeletion->clear(); + } + $this->moduleDescsScheduledForDeletion[]= $moduleDesc; + $moduleDesc->setModule(null); } } @@ -1455,213 +1673,6 @@ abstract class BaseModule extends BaseObject implements Persistent return $this->getGroupModules($query, $con); } - /** - * Clears out the collModuleDescs collection - * - * 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 - * @see addModuleDescs() - */ - public function clearModuleDescs() - { - $this->collModuleDescs = null; // important to set this to null since that means it is uninitialized - $this->collModuleDescsPartial = null; - } - - /** - * reset is the collModuleDescs collection loaded partially - * - * @return void - */ - public function resetPartialModuleDescs($v = true) - { - $this->collModuleDescsPartial = $v; - } - - /** - * Initializes the collModuleDescs collection. - * - * By default this just sets the collModuleDescs collection to an empty array (like clearcollModuleDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initModuleDescs($overrideExisting = true) - { - if (null !== $this->collModuleDescs && !$overrideExisting) { - return; - } - $this->collModuleDescs = new PropelObjectCollection(); - $this->collModuleDescs->setModel('ModuleDesc'); - } - - /** - * Gets an array of ModuleDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Module is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ModuleDesc[] List of ModuleDesc objects - * @throws PropelException - */ - public function getModuleDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collModuleDescsPartial && !$this->isNew(); - if (null === $this->collModuleDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collModuleDescs) { - // return empty collection - $this->initModuleDescs(); - } else { - $collModuleDescs = ModuleDescQuery::create(null, $criteria) - ->filterByModule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collModuleDescsPartial && count($collModuleDescs)) { - $this->initModuleDescs(false); - - foreach($collModuleDescs as $obj) { - if (false == $this->collModuleDescs->contains($obj)) { - $this->collModuleDescs->append($obj); - } - } - - $this->collModuleDescsPartial = true; - } - - return $collModuleDescs; - } - - if($partial && $this->collModuleDescs) { - foreach($this->collModuleDescs as $obj) { - if($obj->isNew()) { - $collModuleDescs[] = $obj; - } - } - } - - $this->collModuleDescs = $collModuleDescs; - $this->collModuleDescsPartial = false; - } - } - - return $this->collModuleDescs; - } - - /** - * Sets a collection of ModuleDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $moduleDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setModuleDescs(PropelCollection $moduleDescs, PropelPDO $con = null) - { - $this->moduleDescsScheduledForDeletion = $this->getModuleDescs(new Criteria(), $con)->diff($moduleDescs); - - foreach ($this->moduleDescsScheduledForDeletion as $moduleDescRemoved) { - $moduleDescRemoved->setModule(null); - } - - $this->collModuleDescs = null; - foreach ($moduleDescs as $moduleDesc) { - $this->addModuleDesc($moduleDesc); - } - - $this->collModuleDescs = $moduleDescs; - $this->collModuleDescsPartial = false; - } - - /** - * Returns the number of related ModuleDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ModuleDesc objects. - * @throws PropelException - */ - public function countModuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collModuleDescsPartial && !$this->isNew(); - if (null === $this->collModuleDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collModuleDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getModuleDescs()); - } - $query = ModuleDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByModule($this) - ->count($con); - } - } else { - return count($this->collModuleDescs); - } - } - - /** - * Method called to associate a ModuleDesc object to this object - * through the ModuleDesc foreign key attribute. - * - * @param ModuleDesc $l ModuleDesc - * @return Module The current object (for fluent API support) - */ - public function addModuleDesc(ModuleDesc $l) - { - if ($this->collModuleDescs === null) { - $this->initModuleDescs(); - $this->collModuleDescsPartial = true; - } - if (!$this->collModuleDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddModuleDesc($l); - } - - return $this; - } - - /** - * @param ModuleDesc $moduleDesc The moduleDesc object to add. - */ - protected function doAddModuleDesc($moduleDesc) - { - $this->collModuleDescs[]= $moduleDesc; - $moduleDesc->setModule($this); - } - - /** - * @param ModuleDesc $moduleDesc The moduleDesc object to remove. - */ - public function removeModuleDesc($moduleDesc) - { - if ($this->getModuleDescs()->contains($moduleDesc)) { - $this->collModuleDescs->remove($this->collModuleDescs->search($moduleDesc)); - if (null === $this->moduleDescsScheduledForDeletion) { - $this->moduleDescsScheduledForDeletion = clone $this->collModuleDescs; - $this->moduleDescsScheduledForDeletion->clear(); - } - $this->moduleDescsScheduledForDeletion[]= $moduleDesc; - $moduleDesc->setModule(null); - } - } - /** * Clears the current object and sets all attributes to their default values */ @@ -1669,7 +1680,7 @@ abstract class BaseModule extends BaseObject implements Persistent { $this->id = null; $this->code = null; - $this->type = null; + $this-> type = null; $this->activate = null; $this->position = null; $this->created_at = null; @@ -1694,26 +1705,26 @@ abstract class BaseModule extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collModuleDescs) { foreach ($this->collModuleDescs as $o) { $o->clearAllReferences($deep); } } + if ($this->collGroupModules) { + foreach ($this->collGroupModules as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collGroupModules instanceof PropelCollection) { - $this->collGroupModules->clearIterator(); - } - $this->collGroupModules = null; if ($this->collModuleDescs instanceof PropelCollection) { $this->collModuleDescs->clearIterator(); } $this->collModuleDescs = null; + if ($this->collGroupModules instanceof PropelCollection) { + $this->collGroupModules->clearIterator(); + } + $this->collGroupModules = null; } /** @@ -1736,4 +1747,18 @@ abstract class BaseModule extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Module The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ModulePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseModuleDesc.php b/core/lib/Thelia/Model/om/BaseModuleDesc.php index 476dbc2b3..f01d9c07a 100644 --- a/core/lib/Thelia/Model/om/BaseModuleDesc.php +++ b/core/lib/Thelia/Model/om/BaseModuleDesc.php @@ -648,8 +648,19 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ModuleDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ModuleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ModuleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1372,4 +1383,18 @@ abstract class BaseModuleDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ModuleDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ModuleDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseModuleDescQuery.php b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php index 8d477930c..6b15d42f2 100644 --- a/core/lib/Thelia/Model/om/BaseModuleDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseModuleDescQuery.php @@ -655,4 +655,69 @@ abstract class BaseModuleDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ModuleDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ModuleDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ModuleDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ModuleDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ModuleDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ModuleDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ModuleDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseModulePeer.php b/core/lib/Thelia/Model/om/BaseModulePeer.php index 6a4ce8b36..da93b3efe 100644 --- a/core/lib/Thelia/Model/om/BaseModulePeer.php +++ b/core/lib/Thelia/Model/om/BaseModulePeer.php @@ -52,8 +52,8 @@ abstract class BaseModulePeer /** 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'; @@ -86,11 +86,11 @@ abstract class BaseModulePeer * e.g. ModulePeer::$fieldNames[ModulePeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Code', 'Type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'type', 'activate', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ModulePeer::ID, ModulePeer::CODE, ModulePeer::TYPE, ModulePeer::ACTIVATE, ModulePeer::POSITION, ModulePeer::CREATED_AT, ModulePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'type', 'activate', 'position', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'Code', ' type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', ' type', 'activate', 'position', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ModulePeer::ID, ModulePeer::CODE, ModulePeer:: TYPE, ModulePeer::ACTIVATE, ModulePeer::POSITION, ModulePeer::CREATED_AT, ModulePeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', ' TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'code', ' type', 'activate', 'position', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -101,11 +101,11 @@ abstract class BaseModulePeer * e.g. ModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (ModulePeer::ID => 0, ModulePeer::CODE => 1, ModulePeer::TYPE => 2, ModulePeer::ACTIVATE => 3, ModulePeer::POSITION => 4, ModulePeer::CREATED_AT => 5, ModulePeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, ' type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, ' type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + BasePeer::TYPE_COLNAME => array (ModulePeer::ID => 0, ModulePeer::CODE => 1, ModulePeer:: TYPE => 2, ModulePeer::ACTIVATE => 3, ModulePeer::POSITION => 4, ModulePeer::CREATED_AT => 5, ModulePeer::UPDATED_AT => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, ' TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, ' type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) ); @@ -182,7 +182,7 @@ abstract class BaseModulePeer if (null === $alias) { $criteria->addSelectColumn(ModulePeer::ID); $criteria->addSelectColumn(ModulePeer::CODE); - $criteria->addSelectColumn(ModulePeer::TYPE); + $criteria->addSelectColumn(ModulePeer:: TYPE); $criteria->addSelectColumn(ModulePeer::ACTIVATE); $criteria->addSelectColumn(ModulePeer::POSITION); $criteria->addSelectColumn(ModulePeer::CREATED_AT); @@ -190,7 +190,7 @@ abstract class BaseModulePeer } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '. TYPE'); $criteria->addSelectColumn($alias . '.ACTIVATE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); @@ -394,12 +394,12 @@ abstract class BaseModulePeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in GroupModulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupModulePeer::clearInstancePool(); // Invalidate objects in ModuleDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ModuleDescPeer::clearInstancePool(); + // Invalidate objects in GroupModulePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + GroupModulePeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/om/BaseModuleQuery.php index 66d427021..fe2102d20 100644 --- a/core/lib/Thelia/Model/om/BaseModuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseModuleQuery.php @@ -25,7 +25,7 @@ use Thelia\Model\ModuleQuery; * * @method ModuleQuery orderById($order = Criteria::ASC) Order by the id column * @method ModuleQuery orderByCode($order = Criteria::ASC) Order by the code column - * @method ModuleQuery orderByType($order = Criteria::ASC) Order by the type column + * @method ModuleQuery orderBy type($order = Criteria::ASC) Order by the type column * @method ModuleQuery orderByActivate($order = Criteria::ASC) Order by the activate column * @method ModuleQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ModuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column @@ -33,7 +33,7 @@ use Thelia\Model\ModuleQuery; * * @method ModuleQuery groupById() Group by the id column * @method ModuleQuery groupByCode() Group by the code column - * @method ModuleQuery groupByType() Group by the type column + * @method ModuleQuery groupBy type() Group by the type column * @method ModuleQuery groupByActivate() Group by the activate column * @method ModuleQuery groupByPosition() Group by the position column * @method ModuleQuery groupByCreatedAt() Group by the created_at column @@ -43,20 +43,20 @@ use Thelia\Model\ModuleQuery; * @method ModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation - * @method ModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation - * @method ModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation - * * @method ModuleQuery leftJoinModuleDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleDesc relation * @method ModuleQuery rightJoinModuleDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleDesc relation * @method ModuleQuery innerJoinModuleDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleDesc relation * + * @method ModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation + * @method ModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation + * @method ModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation + * * @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 findOneByType(int $type) Return the first Module filtered by the type 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 * @method Module findOneByPosition(int $position) Return the first Module filtered by the position column * @method Module findOneByCreatedAt(string $created_at) Return the first Module filtered by the created_at column @@ -64,7 +64,7 @@ use Thelia\Model\ModuleQuery; * * @method array findById(int $id) Return Module objects filtered by the id column * @method array findByCode(string $code) Return Module objects filtered by the code column - * @method array findByType(int $type) Return Module objects filtered by the type column + * @method array findBy type(int $ type) Return Module objects filtered by the type column * @method array findByActivate(int $activate) Return Module objects filtered by the activate column * @method array findByPosition(int $position) Return Module objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return Module objects filtered by the created_at column @@ -158,7 +158,7 @@ abstract class BaseModuleQuery extends ModelCriteria */ 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); @@ -304,16 +304,16 @@ abstract class BaseModuleQuery extends ModelCriteria } /** - * Filter the query on the type column + * Filter the query on the type column * * Example usage: * - * $query->filterByType(1234); // WHERE type = 1234 - * $query->filterByType(array(12, 34)); // WHERE type IN (12, 34) - * $query->filterByType(array('min' => 12)); // WHERE type > 12 + * $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 * * - * @param mixed $type The value to use as filter. + * @param mixed $ type The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -321,16 +321,16 @@ abstract class BaseModuleQuery extends ModelCriteria * * @return ModuleQuery The current query, for fluid interface */ - public function filterByType($type = null, $comparison = null) + public function filterBy type($ type = null, $comparison = null) { - if (is_array($type)) { + if (is_array($ type)) { $useMinMax = false; - if (isset($type['min'])) { - $this->addUsingAlias(ModulePeer::TYPE, $type['min'], Criteria::GREATER_EQUAL); + if (isset($ type['min'])) { + $this->addUsingAlias(ModulePeer:: TYPE, $ type['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($type['max'])) { - $this->addUsingAlias(ModulePeer::TYPE, $type['max'], Criteria::LESS_EQUAL); + if (isset($ type['max'])) { + $this->addUsingAlias(ModulePeer:: TYPE, $ type['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -341,7 +341,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::TYPE, $type, $comparison); + return $this->addUsingAlias(ModulePeer:: TYPE, $ type, $comparison); } /** @@ -512,80 +512,6 @@ abstract class BaseModuleQuery extends ModelCriteria return $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related GroupModule object - * - * @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. - */ - public function filterByGroupModule($groupModule, $comparison = null) - { - if ($groupModule instanceof GroupModule) { - return $this - ->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { - return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupModule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModuleQuery The current query, for fluid interface - */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupModule'); - } - - return $this; - } - - /** - * Use the GroupModule relation GroupModule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query - */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); - } - /** * Filter the query by a related ModuleDesc object * @@ -660,6 +586,80 @@ abstract class BaseModuleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ModuleDesc', '\Thelia\Model\ModuleDescQuery'); } + /** + * Filter the query by a related GroupModule object + * + * @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. + */ + public function filterByGroupModule($groupModule, $comparison = null) + { + if ($groupModule instanceof GroupModule) { + return $this + ->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison); + } elseif ($groupModule instanceof PropelObjectCollection) { + return $this + ->useGroupModuleQuery() + ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the GroupModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ModuleQuery The current query, for fluid interface + */ + public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('GroupModule'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'GroupModule'); + } + + return $this; + } + + /** + * Use the GroupModule relation GroupModule object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query + */ + public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinGroupModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); + } + /** * Exclude object from result * @@ -676,4 +676,69 @@ abstract class BaseModuleQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ModuleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ModulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ModuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ModulePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ModuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ModulePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ModuleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ModulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ModuleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ModulePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ModuleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ModulePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/om/BaseOrder.php index 199a7f43d..01ba6cc1a 100644 --- a/core/lib/Thelia/Model/om/BaseOrder.php +++ b/core/lib/Thelia/Model/om/BaseOrder.php @@ -192,18 +192,18 @@ abstract class BaseOrder extends BaseObject implements Persistent */ protected $aOrderStatus; - /** - * @var PropelObjectCollection|CouponOrder[] Collection to store aggregation of CouponOrder objects. - */ - protected $collCouponOrders; - protected $collCouponOrdersPartial; - /** * @var PropelObjectCollection|OrderProduct[] Collection to store aggregation of OrderProduct objects. */ protected $collOrderProducts; protected $collOrderProductsPartial; + /** + * @var PropelObjectCollection|CouponOrder[] Collection to store aggregation of CouponOrder objects. + */ + protected $collCouponOrders; + protected $collCouponOrdersPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -222,13 +222,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $couponOrdersScheduledForDeletion = null; + protected $orderProductsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $orderProductsScheduledForDeletion = null; + protected $couponOrdersScheduledForDeletion = null; /** * Get the [id] column value. @@ -1035,10 +1035,10 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->aOrderAddressRelatedByAddressInvoice = null; $this->aOrderAddressRelatedByAddressDelivery = null; $this->aOrderStatus = null; - $this->collCouponOrders = null; - $this->collOrderProducts = null; + $this->collCouponOrders = null; + } // if (deep) } @@ -1111,8 +1111,19 @@ abstract class BaseOrder extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1203,23 +1214,6 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->resetModified(); } - if ($this->couponOrdersScheduledForDeletion !== null) { - if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { - CouponOrderQuery::create() - ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->couponOrdersScheduledForDeletion = null; - } - } - - if ($this->collCouponOrders !== null) { - foreach ($this->collCouponOrders as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->orderProductsScheduledForDeletion !== null) { if (!$this->orderProductsScheduledForDeletion->isEmpty()) { OrderProductQuery::create() @@ -1237,6 +1231,23 @@ abstract class BaseOrder extends BaseObject implements Persistent } } + if ($this->couponOrdersScheduledForDeletion !== null) { + if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { + CouponOrderQuery::create() + ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->couponOrdersScheduledForDeletion = null; + } + } + + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -1517,16 +1528,16 @@ abstract class BaseOrder extends BaseObject implements Persistent } - if ($this->collCouponOrders !== null) { - foreach ($this->collCouponOrders as $referrerFK) { + if ($this->collOrderProducts !== null) { + foreach ($this->collOrderProducts as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collOrderProducts !== null) { - foreach ($this->collOrderProducts as $referrerFK) { + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -1686,12 +1697,12 @@ abstract class BaseOrder extends BaseObject implements Persistent if (null !== $this->aOrderStatus) { $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->collCouponOrders) { - $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collOrderProducts) { $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCouponOrders) { + $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1939,18 +1950,18 @@ abstract class BaseOrder extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getCouponOrders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCouponOrder($relObj->copy($deepCopy)); - } - } - foreach ($this->getOrderProducts() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addOrderProduct($relObj->copy($deepCopy)); } } + foreach ($this->getCouponOrders() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCouponOrder($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -2267,218 +2278,11 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function initRelation($relationName) { - if ('CouponOrder' == $relationName) { - $this->initCouponOrders(); - } if ('OrderProduct' == $relationName) { $this->initOrderProducts(); } - } - - /** - * Clears out the collCouponOrders collection - * - * 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 - * @see addCouponOrders() - */ - public function clearCouponOrders() - { - $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized - $this->collCouponOrdersPartial = null; - } - - /** - * reset is the collCouponOrders collection loaded partially - * - * @return void - */ - public function resetPartialCouponOrders($v = true) - { - $this->collCouponOrdersPartial = $v; - } - - /** - * Initializes the collCouponOrders collection. - * - * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCouponOrders($overrideExisting = true) - { - if (null !== $this->collCouponOrders && !$overrideExisting) { - return; - } - $this->collCouponOrders = new PropelObjectCollection(); - $this->collCouponOrders->setModel('CouponOrder'); - } - - /** - * Gets an array of CouponOrder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Order is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CouponOrder[] List of CouponOrder objects - * @throws PropelException - */ - public function getCouponOrders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCouponOrdersPartial && !$this->isNew(); - if (null === $this->collCouponOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponOrders) { - // return empty collection - $this->initCouponOrders(); - } else { - $collCouponOrders = CouponOrderQuery::create(null, $criteria) - ->filterByOrder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { - $this->initCouponOrders(false); - - foreach($collCouponOrders as $obj) { - if (false == $this->collCouponOrders->contains($obj)) { - $this->collCouponOrders->append($obj); - } - } - - $this->collCouponOrdersPartial = true; - } - - return $collCouponOrders; - } - - if($partial && $this->collCouponOrders) { - foreach($this->collCouponOrders as $obj) { - if($obj->isNew()) { - $collCouponOrders[] = $obj; - } - } - } - - $this->collCouponOrders = $collCouponOrders; - $this->collCouponOrdersPartial = false; - } - } - - return $this->collCouponOrders; - } - - /** - * Sets a collection of CouponOrder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $couponOrders A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null) - { - $this->couponOrdersScheduledForDeletion = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - - foreach ($this->couponOrdersScheduledForDeletion as $couponOrderRemoved) { - $couponOrderRemoved->setOrder(null); - } - - $this->collCouponOrders = null; - foreach ($couponOrders as $couponOrder) { - $this->addCouponOrder($couponOrder); - } - - $this->collCouponOrders = $couponOrders; - $this->collCouponOrdersPartial = false; - } - - /** - * Returns the number of related CouponOrder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CouponOrder objects. - * @throws PropelException - */ - public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCouponOrdersPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a CouponOrder object to this object - * through the CouponOrder foreign key attribute. - * - * @param CouponOrder $l CouponOrder - * @return Order The current object (for fluent API support) - */ - public function addCouponOrder(CouponOrder $l) - { - if ($this->collCouponOrders === null) { + if ('CouponOrder' == $relationName) { $this->initCouponOrders(); - $this->collCouponOrdersPartial = true; - } - if (!$this->collCouponOrders->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddCouponOrder($l); - } - - return $this; - } - - /** - * @param CouponOrder $couponOrder The couponOrder object to add. - */ - protected function doAddCouponOrder($couponOrder) - { - $this->collCouponOrders[]= $couponOrder; - $couponOrder->setOrder($this); - } - - /** - * @param CouponOrder $couponOrder The couponOrder object to remove. - */ - public function removeCouponOrder($couponOrder) - { - if ($this->getCouponOrders()->contains($couponOrder)) { - $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); - if (null === $this->couponOrdersScheduledForDeletion) { - $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; - $this->couponOrdersScheduledForDeletion->clear(); - } - $this->couponOrdersScheduledForDeletion[]= $couponOrder; - $couponOrder->setOrder(null); } } @@ -2689,6 +2493,213 @@ abstract class BaseOrder extends BaseObject implements Persistent } } + /** + * Clears out the collCouponOrders collection + * + * 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 + * @see addCouponOrders() + */ + public function clearCouponOrders() + { + $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized + $this->collCouponOrdersPartial = null; + } + + /** + * reset is the collCouponOrders collection loaded partially + * + * @return void + */ + public function resetPartialCouponOrders($v = true) + { + $this->collCouponOrdersPartial = $v; + } + + /** + * Initializes the collCouponOrders collection. + * + * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCouponOrders($overrideExisting = true) + { + if (null !== $this->collCouponOrders && !$overrideExisting) { + return; + } + $this->collCouponOrders = new PropelObjectCollection(); + $this->collCouponOrders->setModel('CouponOrder'); + } + + /** + * Gets an array of CouponOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Order is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|CouponOrder[] List of CouponOrder objects + * @throws PropelException + */ + public function getCouponOrders($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { + // return empty collection + $this->initCouponOrders(); + } else { + $collCouponOrders = CouponOrderQuery::create(null, $criteria) + ->filterByOrder($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { + $this->initCouponOrders(false); + + foreach($collCouponOrders as $obj) { + if (false == $this->collCouponOrders->contains($obj)) { + $this->collCouponOrders->append($obj); + } + } + + $this->collCouponOrdersPartial = true; + } + + return $collCouponOrders; + } + + if($partial && $this->collCouponOrders) { + foreach($this->collCouponOrders as $obj) { + if($obj->isNew()) { + $collCouponOrders[] = $obj; + } + } + } + + $this->collCouponOrders = $collCouponOrders; + $this->collCouponOrdersPartial = false; + } + } + + return $this->collCouponOrders; + } + + /** + * Sets a collection of CouponOrder objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $couponOrders A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null) + { + $this->couponOrdersScheduledForDeletion = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); + + foreach ($this->couponOrdersScheduledForDeletion as $couponOrderRemoved) { + $couponOrderRemoved->setOrder(null); + } + + $this->collCouponOrders = null; + foreach ($couponOrders as $couponOrder) { + $this->addCouponOrder($couponOrder); + } + + $this->collCouponOrders = $couponOrders; + $this->collCouponOrdersPartial = false; + } + + /** + * Returns the number of related CouponOrder objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CouponOrder objects. + * @throws PropelException + */ + public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a CouponOrder object to this object + * through the CouponOrder foreign key attribute. + * + * @param CouponOrder $l CouponOrder + * @return Order The current object (for fluent API support) + */ + public function addCouponOrder(CouponOrder $l) + { + if ($this->collCouponOrders === null) { + $this->initCouponOrders(); + $this->collCouponOrdersPartial = true; + } + if (!$this->collCouponOrders->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddCouponOrder($l); + } + + return $this; + } + + /** + * @param CouponOrder $couponOrder The couponOrder object to add. + */ + protected function doAddCouponOrder($couponOrder) + { + $this->collCouponOrders[]= $couponOrder; + $couponOrder->setOrder($this); + } + + /** + * @param CouponOrder $couponOrder The couponOrder object to remove. + */ + public function removeCouponOrder($couponOrder) + { + if ($this->getCouponOrders()->contains($couponOrder)) { + $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); + if (null === $this->couponOrdersScheduledForDeletion) { + $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; + $this->couponOrdersScheduledForDeletion->clear(); + } + $this->couponOrdersScheduledForDeletion[]= $couponOrder; + $couponOrder->setOrder(null); + } + } + /** * Clears the current object and sets all attributes to their default values */ @@ -2732,26 +2743,26 @@ abstract class BaseOrder extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collCouponOrders) { - foreach ($this->collCouponOrders as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collOrderProducts) { foreach ($this->collOrderProducts as $o) { $o->clearAllReferences($deep); } } + if ($this->collCouponOrders) { + foreach ($this->collCouponOrders as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collCouponOrders instanceof PropelCollection) { - $this->collCouponOrders->clearIterator(); - } - $this->collCouponOrders = null; if ($this->collOrderProducts instanceof PropelCollection) { $this->collOrderProducts->clearIterator(); } $this->collOrderProducts = null; + if ($this->collCouponOrders instanceof PropelCollection) { + $this->collCouponOrders->clearIterator(); + } + $this->collCouponOrders = null; $this->aCurrency = null; $this->aCustomer = null; $this->aOrderAddressRelatedByAddressInvoice = null; @@ -2779,4 +2790,18 @@ abstract class BaseOrder extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Order The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/om/BaseOrderAddress.php index b5115d9f0..eb384ec49 100644 --- a/core/lib/Thelia/Model/om/BaseOrderAddress.php +++ b/core/lib/Thelia/Model/om/BaseOrderAddress.php @@ -855,8 +855,19 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderAddressPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -2256,4 +2267,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return OrderAddress The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderAddressPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php index 848b0a8b4..c571dd9cf 100644 --- a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php @@ -894,4 +894,69 @@ abstract class BaseOrderAddressQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderAddressPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderAddressPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderAddressPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderAddressPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderAddressQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderAddressPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrderFeature.php b/core/lib/Thelia/Model/om/BaseOrderFeature.php index ffbc3aac4..038e1e462 100644 --- a/core/lib/Thelia/Model/om/BaseOrderFeature.php +++ b/core/lib/Thelia/Model/om/BaseOrderFeature.php @@ -534,8 +534,19 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderFeaturePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1207,4 +1218,18 @@ abstract class BaseOrderFeature extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return OrderFeature The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderFeaturePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php index 6e1cb964c..39cd77b29 100644 --- a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php @@ -544,4 +544,69 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderFeaturePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderFeaturePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderFeaturePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderFeatureQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderFeaturePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrderPeer.php b/core/lib/Thelia/Model/om/BaseOrderPeer.php index 1926b7931..bcf1dd95b 100644 --- a/core/lib/Thelia/Model/om/BaseOrderPeer.php +++ b/core/lib/Thelia/Model/om/BaseOrderPeer.php @@ -453,12 +453,12 @@ abstract class BaseOrderPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in CouponOrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CouponOrderPeer::clearInstancePool(); // Invalidate objects in OrderProductPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. OrderProductPeer::clearInstancePool(); + // Invalidate objects in CouponOrderPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CouponOrderPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/om/BaseOrderProduct.php index 191349de4..fd2edc837 100644 --- a/core/lib/Thelia/Model/om/BaseOrderProduct.php +++ b/core/lib/Thelia/Model/om/BaseOrderProduct.php @@ -780,8 +780,19 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1821,4 +1832,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return OrderProduct The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php index 4c741ee18..faac148d3 100644 --- a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php @@ -869,4 +869,69 @@ abstract class BaseOrderProductQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderProductQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/om/BaseOrderQuery.php index c691158b0..765347d96 100644 --- a/core/lib/Thelia/Model/om/BaseOrderQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderQuery.php @@ -89,14 +89,14 @@ use Thelia\Model\OrderStatus; * @method OrderQuery rightJoinOrderStatus($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderStatus relation * @method OrderQuery innerJoinOrderStatus($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderStatus relation * - * @method OrderQuery leftJoinCouponOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponOrder relation - * @method OrderQuery rightJoinCouponOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponOrder relation - * @method OrderQuery innerJoinCouponOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponOrder relation - * * @method OrderQuery leftJoinOrderProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProduct relation * @method OrderQuery rightJoinOrderProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProduct relation * @method OrderQuery innerJoinOrderProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProduct relation * + * @method OrderQuery leftJoinCouponOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponOrder relation + * @method OrderQuery rightJoinCouponOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponOrder relation + * @method OrderQuery innerJoinCouponOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponOrder relation + * * @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 * @@ -1351,80 +1351,6 @@ abstract class BaseOrderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery'); } - /** - * Filter the query by a related CouponOrder object - * - * @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. - */ - public function filterByCouponOrder($couponOrder, $comparison = null) - { - if ($couponOrder instanceof CouponOrder) { - return $this - ->addUsingAlias(OrderPeer::ID, $couponOrder->getOrderId(), $comparison); - } elseif ($couponOrder instanceof PropelObjectCollection) { - return $this - ->useCouponOrderQuery() - ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCouponOrder() only accepts arguments of type CouponOrder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CouponOrder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CouponOrder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CouponOrder'); - } - - return $this; - } - - /** - * Use the CouponOrder relation CouponOrder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query - */ - public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCouponOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); - } - /** * Filter the query by a related OrderProduct object * @@ -1499,6 +1425,80 @@ abstract class BaseOrderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); } + /** + * Filter the query by a related CouponOrder object + * + * @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. + */ + public function filterByCouponOrder($couponOrder, $comparison = null) + { + if ($couponOrder instanceof CouponOrder) { + return $this + ->addUsingAlias(OrderPeer::ID, $couponOrder->getOrderId(), $comparison); + } elseif ($couponOrder instanceof PropelObjectCollection) { + return $this + ->useCouponOrderQuery() + ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCouponOrder() only accepts arguments of type CouponOrder or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CouponOrder relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return OrderQuery The current query, for fluid interface + */ + public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CouponOrder'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CouponOrder'); + } + + return $this; + } + + /** + * Use the CouponOrder relation CouponOrder object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query + */ + public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCouponOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); + } + /** * Exclude object from result * @@ -1515,4 +1515,69 @@ abstract class BaseOrderQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/om/BaseOrderStatus.php index 62c14b0fe..6c146b96c 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatus.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatus.php @@ -477,8 +477,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderStatusPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1657,4 +1668,18 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return OrderStatus The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderStatusPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php index 63d7b25f6..81dbcc692 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusDesc.php @@ -610,8 +610,19 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderStatusDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderStatusDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderStatusDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1317,4 +1328,18 @@ abstract class BaseOrderStatusDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return OrderStatusDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderStatusDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php index 5ad88bed4..05cdf6a44 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusDescQuery.php @@ -610,4 +610,69 @@ abstract class BaseOrderStatusDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderStatusDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderStatusDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderStatusDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderStatusDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderStatusDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderStatusDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderStatusDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php index 9d3a2d1b7..589337a6b 100644 --- a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php +++ b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php @@ -541,4 +541,69 @@ abstract class BaseOrderStatusQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderStatusPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderStatusPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderStatusPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return OrderStatusQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderStatusPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php index bd38bec51..b47d93095 100644 --- a/core/lib/Thelia/Model/om/BaseProduct.php +++ b/core/lib/Thelia/Model/om/BaseProduct.php @@ -118,11 +118,11 @@ abstract class BaseProduct extends BaseObject implements Persistent protected $promo; /** - * The value for the quantity field. + * The value for the stock field. * Note: this column has a database default value of: 0 * @var int */ - protected $quantity; + protected $stock; /** * The value for the visible field. @@ -160,6 +160,48 @@ abstract class BaseProduct extends BaseObject implements Persistent */ protected $aTaxRule; + /** + * @var PropelObjectCollection|ProductDesc[] Collection to store aggregation of ProductDesc objects. + */ + protected $collProductDescs; + protected $collProductDescsPartial; + + /** + * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects. + */ + protected $collProductCategorys; + protected $collProductCategorysPartial; + + /** + * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects. + */ + protected $collFeatureProds; + protected $collFeatureProdsPartial; + + /** + * @var PropelObjectCollection|Stock[] Collection to store aggregation of Stock objects. + */ + protected $collStocks; + protected $collStocksPartial; + + /** + * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. + */ + protected $collContentAssocs; + protected $collContentAssocsPartial; + + /** + * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects. + */ + protected $collImages; + protected $collImagesPartial; + + /** + * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. + */ + protected $collDocuments; + protected $collDocumentsPartial; + /** * @var PropelObjectCollection|Accessory[] Collection to store aggregation of Accessory objects. */ @@ -172,54 +214,12 @@ abstract class BaseProduct extends BaseObject implements Persistent protected $collAccessorysRelatedByAccessory; protected $collAccessorysRelatedByAccessoryPartial; - /** - * @var PropelObjectCollection|ContentAssoc[] Collection to store aggregation of ContentAssoc objects. - */ - protected $collContentAssocs; - protected $collContentAssocsPartial; - - /** - * @var PropelObjectCollection|Document[] Collection to store aggregation of Document objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; - - /** - * @var PropelObjectCollection|FeatureProd[] Collection to store aggregation of FeatureProd objects. - */ - protected $collFeatureProds; - protected $collFeatureProdsPartial; - - /** - * @var PropelObjectCollection|Image[] Collection to store aggregation of Image objects. - */ - protected $collImages; - protected $collImagesPartial; - - /** - * @var PropelObjectCollection|ProductCategory[] Collection to store aggregation of ProductCategory objects. - */ - protected $collProductCategorys; - protected $collProductCategorysPartial; - - /** - * @var PropelObjectCollection|ProductDesc[] Collection to store aggregation of ProductDesc objects. - */ - protected $collProductDescs; - protected $collProductDescsPartial; - /** * @var PropelObjectCollection|Rewriting[] Collection to store aggregation of Rewriting objects. */ protected $collRewritings; protected $collRewritingsPartial; - /** - * @var PropelObjectCollection|Stock[] Collection to store aggregation of Stock objects. - */ - protected $collStocks; - protected $collStocksPartial; - /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -234,6 +234,48 @@ abstract class BaseProduct extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $productDescsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $productCategorysScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $featureProdsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $stocksScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $contentAssocsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $imagesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $documentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var PropelObjectCollection @@ -246,54 +288,12 @@ abstract class BaseProduct extends BaseObject implements Persistent */ protected $accessorysRelatedByAccessoryScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $contentAssocsScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $documentsScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $featureProdsScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $imagesScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $productCategorysScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $productDescsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ protected $rewritingsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var PropelObjectCollection - */ - protected $stocksScheduledForDeletion = null; - /** * Applies default values to this object. * This method should be called from the object's constructor (or @@ -304,7 +304,7 @@ abstract class BaseProduct extends BaseObject implements Persistent { $this->newness = 0; $this->promo = 0; - $this->quantity = 0; + $this->stock = 0; $this->visible = 0; } @@ -399,13 +399,13 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Get the [quantity] column value. + * Get the [stock] column value. * * @return int */ - public function getQuantity() + public function getStock() { - return $this->quantity; + return $this->stock; } /** @@ -685,25 +685,25 @@ abstract class BaseProduct extends BaseObject implements Persistent } // setPromo() /** - * Set the value of [quantity] column. + * Set the value of [stock] column. * * @param int $v new value * @return Product The current object (for fluent API support) */ - public function setQuantity($v) + public function setStock($v) { if ($v !== null) { $v = (int) $v; } - if ($this->quantity !== $v) { - $this->quantity = $v; - $this->modifiedColumns[] = ProductPeer::QUANTITY; + if ($this->stock !== $v) { + $this->stock = $v; + $this->modifiedColumns[] = ProductPeer::STOCK; } return $this; - } // setQuantity() + } // setStock() /** * Set the value of [visible] column. @@ -832,7 +832,7 @@ abstract class BaseProduct extends BaseObject implements Persistent return false; } - if ($this->quantity !== 0) { + if ($this->stock !== 0) { return false; } @@ -870,7 +870,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->ecotax = ($row[$startcol + 5] !== null) ? (double) $row[$startcol + 5] : null; $this->newness = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; $this->promo = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; - $this->quantity = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; + $this->stock = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null; $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; @@ -950,26 +950,26 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? $this->aTaxRule = null; + $this->collProductDescs = null; + + $this->collProductCategorys = null; + + $this->collFeatureProds = null; + + $this->collStocks = null; + + $this->collContentAssocs = null; + + $this->collImages = null; + + $this->collDocuments = null; + $this->collAccessorysRelatedByProductId = null; $this->collAccessorysRelatedByAccessory = null; - $this->collContentAssocs = null; - - $this->collDocuments = null; - - $this->collFeatureProds = null; - - $this->collImages = null; - - $this->collProductCategorys = null; - - $this->collProductDescs = null; - $this->collRewritings = null; - $this->collStocks = null; - } // if (deep) } @@ -1042,8 +1042,19 @@ abstract class BaseProduct extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1106,6 +1117,128 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->resetModified(); } + if ($this->productDescsScheduledForDeletion !== null) { + if (!$this->productDescsScheduledForDeletion->isEmpty()) { + ProductDescQuery::create() + ->filterByPrimaryKeys($this->productDescsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productDescsScheduledForDeletion = null; + } + } + + if ($this->collProductDescs !== null) { + foreach ($this->collProductDescs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->productCategorysScheduledForDeletion !== null) { + if (!$this->productCategorysScheduledForDeletion->isEmpty()) { + ProductCategoryQuery::create() + ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productCategorysScheduledForDeletion = null; + } + } + + if ($this->collProductCategorys !== null) { + foreach ($this->collProductCategorys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->featureProdsScheduledForDeletion !== null) { + if (!$this->featureProdsScheduledForDeletion->isEmpty()) { + FeatureProdQuery::create() + ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->featureProdsScheduledForDeletion = null; + } + } + + if ($this->collFeatureProds !== null) { + foreach ($this->collFeatureProds as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->stocksScheduledForDeletion !== null) { + if (!$this->stocksScheduledForDeletion->isEmpty()) { + StockQuery::create() + ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->stocksScheduledForDeletion = null; + } + } + + if ($this->collStocks !== null) { + foreach ($this->collStocks as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->contentAssocsScheduledForDeletion !== null) { + if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { + foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { + // need to save related object because we set the relation to null + $contentAssoc->save($con); + } + $this->contentAssocsScheduledForDeletion = null; + } + } + + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->imagesScheduledForDeletion !== null) { + if (!$this->imagesScheduledForDeletion->isEmpty()) { + foreach ($this->imagesScheduledForDeletion as $image) { + // need to save related object because we set the relation to null + $image->save($con); + } + $this->imagesScheduledForDeletion = null; + } + } + + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->documentsScheduledForDeletion !== null) { + if (!$this->documentsScheduledForDeletion->isEmpty()) { + foreach ($this->documentsScheduledForDeletion as $document) { + // need to save related object because we set the relation to null + $document->save($con); + } + $this->documentsScheduledForDeletion = null; + } + } + + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->accessorysRelatedByProductIdScheduledForDeletion !== null) { if (!$this->accessorysRelatedByProductIdScheduledForDeletion->isEmpty()) { AccessoryQuery::create() @@ -1140,111 +1273,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureProdsScheduledForDeletion !== null) { - if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - FeatureProdQuery::create() - ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureProdsScheduledForDeletion = null; - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - foreach ($this->imagesScheduledForDeletion as $image) { - // need to save related object because we set the relation to null - $image->save($con); - } - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productCategorysScheduledForDeletion = null; - } - } - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->productDescsScheduledForDeletion !== null) { - if (!$this->productDescsScheduledForDeletion->isEmpty()) { - ProductDescQuery::create() - ->filterByPrimaryKeys($this->productDescsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productDescsScheduledForDeletion = null; - } - } - - if ($this->collProductDescs !== null) { - foreach ($this->collProductDescs as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { foreach ($this->rewritingsScheduledForDeletion as $rewriting) { @@ -1263,23 +1291,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - if ($this->stocksScheduledForDeletion !== null) { - if (!$this->stocksScheduledForDeletion->isEmpty()) { - StockQuery::create() - ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->stocksScheduledForDeletion = null; - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - $this->alreadyInSave = false; } @@ -1330,8 +1341,8 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->isColumnModified(ProductPeer::PROMO)) { $modifiedColumns[':p' . $index++] = '`PROMO`'; } - if ($this->isColumnModified(ProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`QUANTITY`'; + if ($this->isColumnModified(ProductPeer::STOCK)) { + $modifiedColumns[':p' . $index++] = '`STOCK`'; } if ($this->isColumnModified(ProductPeer::VISIBLE)) { $modifiedColumns[':p' . $index++] = '`VISIBLE`'; @@ -1383,8 +1394,8 @@ abstract class BaseProduct extends BaseObject implements Persistent case '`PROMO`': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; - case '`QUANTITY`': - $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT); + case '`STOCK`': + $stmt->bindValue($identifier, $this->stock, PDO::PARAM_INT); break; case '`VISIBLE`': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); @@ -1512,6 +1523,62 @@ abstract class BaseProduct extends BaseObject implements Persistent } + if ($this->collProductDescs !== null) { + foreach ($this->collProductDescs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collProductCategorys !== null) { + foreach ($this->collProductCategorys as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collFeatureProds !== null) { + foreach ($this->collFeatureProds as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collStocks !== null) { + foreach ($this->collStocks as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + if ($this->collAccessorysRelatedByProductId !== null) { foreach ($this->collAccessorysRelatedByProductId as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -1528,54 +1595,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collProductDescs !== null) { - foreach ($this->collProductDescs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - if ($this->collRewritings !== null) { foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->validate($columns)) { @@ -1584,14 +1603,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - $this->alreadyInValidation = false; } @@ -1652,7 +1663,7 @@ abstract class BaseProduct extends BaseObject implements Persistent return $this->getPromo(); break; case 8: - return $this->getQuantity(); + return $this->getStock(); break; case 9: return $this->getVisible(); @@ -1706,7 +1717,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $keys[5] => $this->getEcotax(), $keys[6] => $this->getNewness(), $keys[7] => $this->getPromo(), - $keys[8] => $this->getQuantity(), + $keys[8] => $this->getStock(), $keys[9] => $this->getVisible(), $keys[10] => $this->getWeight(), $keys[11] => $this->getPosition(), @@ -1717,36 +1728,36 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->aTaxRule) { $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->collProductDescs) { + $result['ProductDescs'] = $this->collProductDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collProductCategorys) { + $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collFeatureProds) { + $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collStocks) { + $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collContentAssocs) { + $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collImages) { + $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collDocuments) { + $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collAccessorysRelatedByProductId) { $result['AccessorysRelatedByProductId'] = $this->collAccessorysRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collAccessorysRelatedByAccessory) { $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureProds) { - $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collProductCategorys) { - $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collProductDescs) { - $result['ProductDescs'] = $this->collProductDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collStocks) { - $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } } return $result; @@ -1806,7 +1817,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->setPromo($value); break; case 8: - $this->setQuantity($value); + $this->setStock($value); break; case 9: $this->setVisible($value); @@ -1855,7 +1866,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]); + if (array_key_exists($keys[8], $arr)) $this->setStock($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]); @@ -1880,7 +1891,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->isColumnModified(ProductPeer::ECOTAX)) $criteria->add(ProductPeer::ECOTAX, $this->ecotax); if ($this->isColumnModified(ProductPeer::NEWNESS)) $criteria->add(ProductPeer::NEWNESS, $this->newness); if ($this->isColumnModified(ProductPeer::PROMO)) $criteria->add(ProductPeer::PROMO, $this->promo); - if ($this->isColumnModified(ProductPeer::QUANTITY)) $criteria->add(ProductPeer::QUANTITY, $this->quantity); + if ($this->isColumnModified(ProductPeer::STOCK)) $criteria->add(ProductPeer::STOCK, $this->stock); if ($this->isColumnModified(ProductPeer::VISIBLE)) $criteria->add(ProductPeer::VISIBLE, $this->visible); if ($this->isColumnModified(ProductPeer::WEIGHT)) $criteria->add(ProductPeer::WEIGHT, $this->weight); if ($this->isColumnModified(ProductPeer::POSITION)) $criteria->add(ProductPeer::POSITION, $this->position); @@ -1956,7 +1967,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $copyObj->setEcotax($this->getEcotax()); $copyObj->setNewness($this->getNewness()); $copyObj->setPromo($this->getPromo()); - $copyObj->setQuantity($this->getQuantity()); + $copyObj->setStock($this->getStock()); $copyObj->setVisible($this->getVisible()); $copyObj->setWeight($this->getWeight()); $copyObj->setPosition($this->getPosition()); @@ -1970,6 +1981,48 @@ abstract class BaseProduct extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; + foreach ($this->getProductDescs() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductDesc($relObj->copy($deepCopy)); + } + } + + foreach ($this->getProductCategorys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductCategory($relObj->copy($deepCopy)); + } + } + + foreach ($this->getFeatureProds() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFeatureProd($relObj->copy($deepCopy)); + } + } + + foreach ($this->getStocks() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addStock($relObj->copy($deepCopy)); + } + } + + foreach ($this->getContentAssocs() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentAssoc($relObj->copy($deepCopy)); + } + } + + foreach ($this->getImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getAccessorysRelatedByProductId() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAccessoryRelatedByProductId($relObj->copy($deepCopy)); @@ -1982,54 +2035,12 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureProds() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureProd($relObj->copy($deepCopy)); - } - } - - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getProductCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getProductDescs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductDesc($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); } } - foreach ($this->getStocks() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addStock($relObj->copy($deepCopy)); - } - } - //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -2142,36 +2153,1785 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('ProductDesc' == $relationName) { + $this->initProductDescs(); + } + if ('ProductCategory' == $relationName) { + $this->initProductCategorys(); + } + if ('FeatureProd' == $relationName) { + $this->initFeatureProds(); + } + if ('Stock' == $relationName) { + $this->initStocks(); + } + if ('ContentAssoc' == $relationName) { + $this->initContentAssocs(); + } + if ('Image' == $relationName) { + $this->initImages(); + } + if ('Document' == $relationName) { + $this->initDocuments(); + } if ('AccessoryRelatedByProductId' == $relationName) { $this->initAccessorysRelatedByProductId(); } if ('AccessoryRelatedByAccessory' == $relationName) { $this->initAccessorysRelatedByAccessory(); } - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); - } - if ('Image' == $relationName) { - $this->initImages(); - } - if ('ProductCategory' == $relationName) { - $this->initProductCategorys(); - } - if ('ProductDesc' == $relationName) { - $this->initProductDescs(); - } if ('Rewriting' == $relationName) { $this->initRewritings(); } - if ('Stock' == $relationName) { - $this->initStocks(); + } + + /** + * Clears out the collProductDescs collection + * + * 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 + * @see addProductDescs() + */ + public function clearProductDescs() + { + $this->collProductDescs = null; // important to set this to null since that means it is uninitialized + $this->collProductDescsPartial = null; + } + + /** + * reset is the collProductDescs collection loaded partially + * + * @return void + */ + public function resetPartialProductDescs($v = true) + { + $this->collProductDescsPartial = $v; + } + + /** + * Initializes the collProductDescs collection. + * + * By default this just sets the collProductDescs collection to an empty array (like clearcollProductDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductDescs($overrideExisting = true) + { + if (null !== $this->collProductDescs && !$overrideExisting) { + return; } + $this->collProductDescs = new PropelObjectCollection(); + $this->collProductDescs->setModel('ProductDesc'); + } + + /** + * Gets an array of ProductDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ProductDesc[] List of ProductDesc objects + * @throws PropelException + */ + public function getProductDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collProductDescsPartial && !$this->isNew(); + if (null === $this->collProductDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDescs) { + // return empty collection + $this->initProductDescs(); + } else { + $collProductDescs = ProductDescQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collProductDescsPartial && count($collProductDescs)) { + $this->initProductDescs(false); + + foreach($collProductDescs as $obj) { + if (false == $this->collProductDescs->contains($obj)) { + $this->collProductDescs->append($obj); + } + } + + $this->collProductDescsPartial = true; + } + + return $collProductDescs; + } + + if($partial && $this->collProductDescs) { + foreach($this->collProductDescs as $obj) { + if($obj->isNew()) { + $collProductDescs[] = $obj; + } + } + } + + $this->collProductDescs = $collProductDescs; + $this->collProductDescsPartial = false; + } + } + + return $this->collProductDescs; + } + + /** + * Sets a collection of ProductDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $productDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setProductDescs(PropelCollection $productDescs, PropelPDO $con = null) + { + $this->productDescsScheduledForDeletion = $this->getProductDescs(new Criteria(), $con)->diff($productDescs); + + foreach ($this->productDescsScheduledForDeletion as $productDescRemoved) { + $productDescRemoved->setProduct(null); + } + + $this->collProductDescs = null; + foreach ($productDescs as $productDesc) { + $this->addProductDesc($productDesc); + } + + $this->collProductDescs = $productDescs; + $this->collProductDescsPartial = false; + } + + /** + * Returns the number of related ProductDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ProductDesc objects. + * @throws PropelException + */ + public function countProductDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collProductDescsPartial && !$this->isNew(); + if (null === $this->collProductDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getProductDescs()); + } + $query = ProductDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProduct($this) + ->count($con); + } + } else { + return count($this->collProductDescs); + } + } + + /** + * Method called to associate a ProductDesc object to this object + * through the ProductDesc foreign key attribute. + * + * @param ProductDesc $l ProductDesc + * @return Product The current object (for fluent API support) + */ + public function addProductDesc(ProductDesc $l) + { + if ($this->collProductDescs === null) { + $this->initProductDescs(); + $this->collProductDescsPartial = true; + } + if (!$this->collProductDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddProductDesc($l); + } + + return $this; + } + + /** + * @param ProductDesc $productDesc The productDesc object to add. + */ + protected function doAddProductDesc($productDesc) + { + $this->collProductDescs[]= $productDesc; + $productDesc->setProduct($this); + } + + /** + * @param ProductDesc $productDesc The productDesc object to remove. + */ + public function removeProductDesc($productDesc) + { + if ($this->getProductDescs()->contains($productDesc)) { + $this->collProductDescs->remove($this->collProductDescs->search($productDesc)); + if (null === $this->productDescsScheduledForDeletion) { + $this->productDescsScheduledForDeletion = clone $this->collProductDescs; + $this->productDescsScheduledForDeletion->clear(); + } + $this->productDescsScheduledForDeletion[]= $productDesc; + $productDesc->setProduct(null); + } + } + + /** + * Clears out the collProductCategorys collection + * + * 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 + * @see addProductCategorys() + */ + public function clearProductCategorys() + { + $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized + $this->collProductCategorysPartial = null; + } + + /** + * reset is the collProductCategorys collection loaded partially + * + * @return void + */ + public function resetPartialProductCategorys($v = true) + { + $this->collProductCategorysPartial = $v; + } + + /** + * Initializes the collProductCategorys collection. + * + * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductCategorys($overrideExisting = true) + { + if (null !== $this->collProductCategorys && !$overrideExisting) { + return; + } + $this->collProductCategorys = new PropelObjectCollection(); + $this->collProductCategorys->setModel('ProductCategory'); + } + + /** + * Gets an array of ProductCategory objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + * @throws PropelException + */ + public function getProductCategorys($criteria = null, PropelPDO $con = null) + { + $partial = $this->collProductCategorysPartial && !$this->isNew(); + if (null === $this->collProductCategorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategorys) { + // return empty collection + $this->initProductCategorys(); + } else { + $collProductCategorys = ProductCategoryQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { + $this->initProductCategorys(false); + + foreach($collProductCategorys as $obj) { + if (false == $this->collProductCategorys->contains($obj)) { + $this->collProductCategorys->append($obj); + } + } + + $this->collProductCategorysPartial = true; + } + + return $collProductCategorys; + } + + if($partial && $this->collProductCategorys) { + foreach($this->collProductCategorys as $obj) { + if($obj->isNew()) { + $collProductCategorys[] = $obj; + } + } + } + + $this->collProductCategorys = $collProductCategorys; + $this->collProductCategorysPartial = false; + } + } + + return $this->collProductCategorys; + } + + /** + * Sets a collection of ProductCategory objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $productCategorys A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) + { + $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + + foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { + $productCategoryRemoved->setProduct(null); + } + + $this->collProductCategorys = null; + foreach ($productCategorys as $productCategory) { + $this->addProductCategory($productCategory); + } + + $this->collProductCategorys = $productCategorys; + $this->collProductCategorysPartial = false; + } + + /** + * Returns the number of related ProductCategory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ProductCategory objects. + * @throws PropelException + */ + public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collProductCategorysPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a ProductCategory object to this object + * through the ProductCategory foreign key attribute. + * + * @param ProductCategory $l ProductCategory + * @return Product The current object (for fluent API support) + */ + public function addProductCategory(ProductCategory $l) + { + if ($this->collProductCategorys === null) { + $this->initProductCategorys(); + $this->collProductCategorysPartial = true; + } + if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddProductCategory($l); + } + + return $this; + } + + /** + * @param ProductCategory $productCategory The productCategory object to add. + */ + protected function doAddProductCategory($productCategory) + { + $this->collProductCategorys[]= $productCategory; + $productCategory->setProduct($this); + } + + /** + * @param ProductCategory $productCategory The productCategory object to remove. + */ + public function removeProductCategory($productCategory) + { + if ($this->getProductCategorys()->contains($productCategory)) { + $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); + if (null === $this->productCategorysScheduledForDeletion) { + $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; + $this->productCategorysScheduledForDeletion->clear(); + } + $this->productCategorysScheduledForDeletion[]= $productCategory; + $productCategory->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related ProductCategorys from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects + */ + public function getProductCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ProductCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getProductCategorys($query, $con); + } + + /** + * Clears out the collFeatureProds collection + * + * 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 + * @see addFeatureProds() + */ + public function clearFeatureProds() + { + $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized + $this->collFeatureProdsPartial = null; + } + + /** + * reset is the collFeatureProds collection loaded partially + * + * @return void + */ + public function resetPartialFeatureProds($v = true) + { + $this->collFeatureProdsPartial = $v; + } + + /** + * Initializes the collFeatureProds collection. + * + * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFeatureProds($overrideExisting = true) + { + if (null !== $this->collFeatureProds && !$overrideExisting) { + return; + } + $this->collFeatureProds = new PropelObjectCollection(); + $this->collFeatureProds->setModel('FeatureProd'); + } + + /** + * Gets an array of FeatureProd objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + * @throws PropelException + */ + public function getFeatureProds($criteria = null, PropelPDO $con = null) + { + $partial = $this->collFeatureProdsPartial && !$this->isNew(); + if (null === $this->collFeatureProds || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureProds) { + // return empty collection + $this->initFeatureProds(); + } else { + $collFeatureProds = FeatureProdQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { + $this->initFeatureProds(false); + + foreach($collFeatureProds as $obj) { + if (false == $this->collFeatureProds->contains($obj)) { + $this->collFeatureProds->append($obj); + } + } + + $this->collFeatureProdsPartial = true; + } + + return $collFeatureProds; + } + + if($partial && $this->collFeatureProds) { + foreach($this->collFeatureProds as $obj) { + if($obj->isNew()) { + $collFeatureProds[] = $obj; + } + } + } + + $this->collFeatureProds = $collFeatureProds; + $this->collFeatureProdsPartial = false; + } + } + + return $this->collFeatureProds; + } + + /** + * Sets a collection of FeatureProd objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $featureProds A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) + { + $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); + + foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { + $featureProdRemoved->setProduct(null); + } + + $this->collFeatureProds = null; + foreach ($featureProds as $featureProd) { + $this->addFeatureProd($featureProd); + } + + $this->collFeatureProds = $featureProds; + $this->collFeatureProdsPartial = false; + } + + /** + * Returns the number of related FeatureProd objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related FeatureProd objects. + * @throws PropelException + */ + public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collFeatureProdsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a FeatureProd object to this object + * through the FeatureProd foreign key attribute. + * + * @param FeatureProd $l FeatureProd + * @return Product The current object (for fluent API support) + */ + public function addFeatureProd(FeatureProd $l) + { + if ($this->collFeatureProds === null) { + $this->initFeatureProds(); + $this->collFeatureProdsPartial = true; + } + if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddFeatureProd($l); + } + + return $this; + } + + /** + * @param FeatureProd $featureProd The featureProd object to add. + */ + protected function doAddFeatureProd($featureProd) + { + $this->collFeatureProds[]= $featureProd; + $featureProd->setProduct($this); + } + + /** + * @param FeatureProd $featureProd The featureProd object to remove. + */ + public function removeFeatureProd($featureProd) + { + if ($this->getFeatureProds()->contains($featureProd)) { + $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); + if (null === $this->featureProdsScheduledForDeletion) { + $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; + $this->featureProdsScheduledForDeletion->clear(); + } + $this->featureProdsScheduledForDeletion[]= $featureProd; + $featureProd->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related FeatureProds from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + */ + public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = FeatureProdQuery::create(null, $criteria); + $query->joinWith('Feature', $join_behavior); + + return $this->getFeatureProds($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related FeatureProds from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects + */ + public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = FeatureProdQuery::create(null, $criteria); + $query->joinWith('FeatureAv', $join_behavior); + + return $this->getFeatureProds($query, $con); + } + + /** + * Clears out the collStocks collection + * + * 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 + * @see addStocks() + */ + public function clearStocks() + { + $this->collStocks = null; // important to set this to null since that means it is uninitialized + $this->collStocksPartial = null; + } + + /** + * reset is the collStocks collection loaded partially + * + * @return void + */ + public function resetPartialStocks($v = true) + { + $this->collStocksPartial = $v; + } + + /** + * Initializes the collStocks collection. + * + * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initStocks($overrideExisting = true) + { + if (null !== $this->collStocks && !$overrideExisting) { + return; + } + $this->collStocks = new PropelObjectCollection(); + $this->collStocks->setModel('Stock'); + } + + /** + * Gets an array of Stock objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Stock[] List of Stock objects + * @throws PropelException + */ + public function getStocks($criteria = null, PropelPDO $con = null) + { + $partial = $this->collStocksPartial && !$this->isNew(); + if (null === $this->collStocks || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collStocks) { + // return empty collection + $this->initStocks(); + } else { + $collStocks = StockQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collStocksPartial && count($collStocks)) { + $this->initStocks(false); + + foreach($collStocks as $obj) { + if (false == $this->collStocks->contains($obj)) { + $this->collStocks->append($obj); + } + } + + $this->collStocksPartial = true; + } + + return $collStocks; + } + + if($partial && $this->collStocks) { + foreach($this->collStocks as $obj) { + if($obj->isNew()) { + $collStocks[] = $obj; + } + } + } + + $this->collStocks = $collStocks; + $this->collStocksPartial = false; + } + } + + return $this->collStocks; + } + + /** + * Sets a collection of Stock objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $stocks A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setStocks(PropelCollection $stocks, PropelPDO $con = null) + { + $this->stocksScheduledForDeletion = $this->getStocks(new Criteria(), $con)->diff($stocks); + + foreach ($this->stocksScheduledForDeletion as $stockRemoved) { + $stockRemoved->setProduct(null); + } + + $this->collStocks = null; + foreach ($stocks as $stock) { + $this->addStock($stock); + } + + $this->collStocks = $stocks; + $this->collStocksPartial = false; + } + + /** + * Returns the number of related Stock objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Stock objects. + * @throws PropelException + */ + public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collStocksPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Stock object to this object + * through the Stock foreign key attribute. + * + * @param Stock $l Stock + * @return Product The current object (for fluent API support) + */ + public function addStock(Stock $l) + { + if ($this->collStocks === null) { + $this->initStocks(); + $this->collStocksPartial = true; + } + if (!$this->collStocks->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddStock($l); + } + + return $this; + } + + /** + * @param Stock $stock The stock object to add. + */ + protected function doAddStock($stock) + { + $this->collStocks[]= $stock; + $stock->setProduct($this); + } + + /** + * @param Stock $stock The stock object to remove. + */ + public function removeStock($stock) + { + if ($this->getStocks()->contains($stock)) { + $this->collStocks->remove($this->collStocks->search($stock)); + if (null === $this->stocksScheduledForDeletion) { + $this->stocksScheduledForDeletion = clone $this->collStocks; + $this->stocksScheduledForDeletion->clear(); + } + $this->stocksScheduledForDeletion[]= $stock; + $stock->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Stocks from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Stock[] List of Stock objects + */ + public function getStocksJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = StockQuery::create(null, $criteria); + $query->joinWith('Combination', $join_behavior); + + return $this->getStocks($query, $con); + } + + /** + * Clears out the collContentAssocs collection + * + * 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 + * @see addContentAssocs() + */ + public function clearContentAssocs() + { + $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized + $this->collContentAssocsPartial = null; + } + + /** + * reset is the collContentAssocs collection loaded partially + * + * @return void + */ + public function resetPartialContentAssocs($v = true) + { + $this->collContentAssocsPartial = $v; + } + + /** + * Initializes the collContentAssocs collection. + * + * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentAssocs($overrideExisting = true) + { + if (null !== $this->collContentAssocs && !$overrideExisting) { + return; + } + $this->collContentAssocs = new PropelObjectCollection(); + $this->collContentAssocs->setModel('ContentAssoc'); + } + + /** + * Gets an array of ContentAssoc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects + * @throws PropelException + */ + public function getContentAssocs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collContentAssocsPartial && !$this->isNew(); + if (null === $this->collContentAssocs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentAssocs) { + // return empty collection + $this->initContentAssocs(); + } else { + $collContentAssocs = ContentAssocQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { + $this->initContentAssocs(false); + + foreach($collContentAssocs as $obj) { + if (false == $this->collContentAssocs->contains($obj)) { + $this->collContentAssocs->append($obj); + } + } + + $this->collContentAssocsPartial = true; + } + + return $collContentAssocs; + } + + if($partial && $this->collContentAssocs) { + foreach($this->collContentAssocs as $obj) { + if($obj->isNew()) { + $collContentAssocs[] = $obj; + } + } + } + + $this->collContentAssocs = $collContentAssocs; + $this->collContentAssocsPartial = false; + } + } + + return $this->collContentAssocs; + } + + /** + * Sets a collection of ContentAssoc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $contentAssocs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) + { + $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); + + foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) { + $contentAssocRemoved->setProduct(null); + } + + $this->collContentAssocs = null; + foreach ($contentAssocs as $contentAssoc) { + $this->addContentAssoc($contentAssoc); + } + + $this->collContentAssocs = $contentAssocs; + $this->collContentAssocsPartial = false; + } + + /** + * Returns the number of related ContentAssoc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ContentAssoc objects. + * @throws PropelException + */ + public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collContentAssocsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a ContentAssoc object to this object + * through the ContentAssoc foreign key attribute. + * + * @param ContentAssoc $l ContentAssoc + * @return Product The current object (for fluent API support) + */ + public function addContentAssoc(ContentAssoc $l) + { + if ($this->collContentAssocs === null) { + $this->initContentAssocs(); + $this->collContentAssocsPartial = true; + } + if (!$this->collContentAssocs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddContentAssoc($l); + } + + return $this; + } + + /** + * @param ContentAssoc $contentAssoc The contentAssoc object to add. + */ + protected function doAddContentAssoc($contentAssoc) + { + $this->collContentAssocs[]= $contentAssoc; + $contentAssoc->setProduct($this); + } + + /** + * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + */ + public function removeContentAssoc($contentAssoc) + { + if ($this->getContentAssocs()->contains($contentAssoc)) { + $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); + if (null === $this->contentAssocsScheduledForDeletion) { + $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; + $this->contentAssocsScheduledForDeletion->clear(); + } + $this->contentAssocsScheduledForDeletion[]= $contentAssoc; + $contentAssoc->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related ContentAssocs from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects + */ + public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ContentAssocQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getContentAssocs($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related ContentAssocs from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects + */ + public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ContentAssocQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getContentAssocs($query, $con); + } + + /** + * Clears out the collImages collection + * + * 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 + * @see addImages() + */ + public function clearImages() + { + $this->collImages = null; // important to set this to null since that means it is uninitialized + $this->collImagesPartial = null; + } + + /** + * reset is the collImages collection loaded partially + * + * @return void + */ + public function resetPartialImages($v = true) + { + $this->collImagesPartial = $v; + } + + /** + * Initializes the collImages collection. + * + * By default this just sets the collImages collection to an empty array (like clearcollImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initImages($overrideExisting = true) + { + if (null !== $this->collImages && !$overrideExisting) { + return; + } + $this->collImages = new PropelObjectCollection(); + $this->collImages->setModel('Image'); + } + + /** + * Gets an array of Image objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Image[] List of Image objects + * @throws PropelException + */ + public function getImages($criteria = null, PropelPDO $con = null) + { + $partial = $this->collImagesPartial && !$this->isNew(); + if (null === $this->collImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collImages) { + // return empty collection + $this->initImages(); + } else { + $collImages = ImageQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collImagesPartial && count($collImages)) { + $this->initImages(false); + + foreach($collImages as $obj) { + if (false == $this->collImages->contains($obj)) { + $this->collImages->append($obj); + } + } + + $this->collImagesPartial = true; + } + + return $collImages; + } + + if($partial && $this->collImages) { + foreach($this->collImages as $obj) { + if($obj->isNew()) { + $collImages[] = $obj; + } + } + } + + $this->collImages = $collImages; + $this->collImagesPartial = false; + } + } + + return $this->collImages; + } + + /** + * Sets a collection of Image objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $images A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setImages(PropelCollection $images, PropelPDO $con = null) + { + $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); + + foreach ($this->imagesScheduledForDeletion as $imageRemoved) { + $imageRemoved->setProduct(null); + } + + $this->collImages = null; + foreach ($images as $image) { + $this->addImage($image); + } + + $this->collImages = $images; + $this->collImagesPartial = false; + } + + /** + * Returns the number of related Image objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Image objects. + * @throws PropelException + */ + public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collImagesPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Image object to this object + * through the Image foreign key attribute. + * + * @param Image $l Image + * @return Product The current object (for fluent API support) + */ + public function addImage(Image $l) + { + if ($this->collImages === null) { + $this->initImages(); + $this->collImagesPartial = true; + } + if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddImage($l); + } + + return $this; + } + + /** + * @param Image $image The image object to add. + */ + protected function doAddImage($image) + { + $this->collImages[]= $image; + $image->setProduct($this); + } + + /** + * @param Image $image The image object to remove. + */ + public function removeImage($image) + { + if ($this->getImages()->contains($image)) { + $this->collImages->remove($this->collImages->search($image)); + if (null === $this->imagesScheduledForDeletion) { + $this->imagesScheduledForDeletion = clone $this->collImages; + $this->imagesScheduledForDeletion->clear(); + } + $this->imagesScheduledForDeletion[]= $image; + $image->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Images from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Image[] List of Image objects + */ + public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ImageQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getImages($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Images from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Image[] List of Image objects + */ + public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ImageQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getImages($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Images from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Image[] List of Image objects + */ + public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = ImageQuery::create(null, $criteria); + $query->joinWith('Folder', $join_behavior); + + return $this->getImages($query, $con); + } + + /** + * Clears out the collDocuments collection + * + * 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 + * @see addDocuments() + */ + public function clearDocuments() + { + $this->collDocuments = null; // important to set this to null since that means it is uninitialized + $this->collDocumentsPartial = null; + } + + /** + * reset is the collDocuments collection loaded partially + * + * @return void + */ + public function resetPartialDocuments($v = true) + { + $this->collDocumentsPartial = $v; + } + + /** + * Initializes the collDocuments collection. + * + * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initDocuments($overrideExisting = true) + { + if (null !== $this->collDocuments && !$overrideExisting) { + return; + } + $this->collDocuments = new PropelObjectCollection(); + $this->collDocuments->setModel('Document'); + } + + /** + * Gets an array of Document objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Product is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|Document[] List of Document objects + * @throws PropelException + */ + public function getDocuments($criteria = null, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + if (null === $this->collDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collDocuments) { + // return empty collection + $this->initDocuments(); + } else { + $collDocuments = DocumentQuery::create(null, $criteria) + ->filterByProduct($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collDocumentsPartial && count($collDocuments)) { + $this->initDocuments(false); + + foreach($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } + } + + $this->collDocumentsPartial = true; + } + + return $collDocuments; + } + + if($partial && $this->collDocuments) { + foreach($this->collDocuments as $obj) { + if($obj->isNew()) { + $collDocuments[] = $obj; + } + } + } + + $this->collDocuments = $collDocuments; + $this->collDocumentsPartial = false; + } + } + + return $this->collDocuments; + } + + /** + * Sets a collection of Document objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $documents A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + { + $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); + + foreach ($this->documentsScheduledForDeletion as $documentRemoved) { + $documentRemoved->setProduct(null); + } + + $this->collDocuments = null; + foreach ($documents as $document) { + $this->addDocument($document); + } + + $this->collDocuments = $documents; + $this->collDocumentsPartial = false; + } + + /** + * Returns the number of related Document objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Document objects. + * @throws PropelException + */ + public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collDocumentsPartial && !$this->isNew(); + 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); + } + } + + /** + * Method called to associate a Document object to this object + * through the Document foreign key attribute. + * + * @param Document $l Document + * @return Product The current object (for fluent API support) + */ + public function addDocument(Document $l) + { + if ($this->collDocuments === null) { + $this->initDocuments(); + $this->collDocumentsPartial = true; + } + if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddDocument($l); + } + + return $this; + } + + /** + * @param Document $document The document object to add. + */ + protected function doAddDocument($document) + { + $this->collDocuments[]= $document; + $document->setProduct($this); + } + + /** + * @param Document $document The document object to remove. + */ + public function removeDocument($document) + { + if ($this->getDocuments()->contains($document)) { + $this->collDocuments->remove($this->collDocuments->search($document)); + if (null === $this->documentsScheduledForDeletion) { + $this->documentsScheduledForDeletion = clone $this->collDocuments; + $this->documentsScheduledForDeletion->clear(); + } + $this->documentsScheduledForDeletion[]= $document; + $document->setProduct(null); + } + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Category', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Content', $join_behavior); + + return $this->getDocuments($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Product is new, it will return + * an empty collection; or if this Product has previously + * been saved, it will retrieve related Documents from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Product. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return PropelObjectCollection|Document[] List of Document objects + */ + public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = DocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $join_behavior); + + return $this->getDocuments($query, $con); } /** @@ -2588,1523 +4348,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - /** - * Clears out the collContentAssocs collection - * - * 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 - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - } - - /** - * reset is the collContentAssocs collection loaded partially - * - * @return void - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); - } - - /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - return $collContentAssocs; - } - - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentAssocs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) - { - $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) { - $contentAssocRemoved->setProduct(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. - * - * @param ContentAssoc $l ContentAssoc - * @return Product The current object (for fluent API support) - */ - public function addContentAssoc(ContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - if (!$this->collContentAssocs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setProduct($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * 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 - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents); - - foreach ($this->documentsScheduledForDeletion as $documentRemoved) { - $documentRemoved->setProduct(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Product The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!$this->collDocuments->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setProduct($this); - } - - /** - * @param Document $document The document object to remove. - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collFeatureProds collection - * - * 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 - * @see addFeatureProds() - */ - public function clearFeatureProds() - { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - } - - /** - * reset is the collFeatureProds collection loaded partially - * - * @return void - */ - public function resetPartialFeatureProds($v = true) - { - $this->collFeatureProdsPartial = $v; - } - - /** - * Initializes the collFeatureProds collection. - * - * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureProds($overrideExisting = true) - { - if (null !== $this->collFeatureProds && !$overrideExisting) { - return; - } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); - } - - /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - * @throws PropelException - */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - // return empty collection - $this->initFeatureProds(); - } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); - - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); - } - } - - $this->collFeatureProdsPartial = true; - } - - return $collFeatureProds; - } - - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { - $collFeatureProds[] = $obj; - } - } - } - - $this->collFeatureProds = $collFeatureProds; - $this->collFeatureProdsPartial = false; - } - } - - return $this->collFeatureProds; - } - - /** - * Sets a collection of FeatureProd objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureProds A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) - { - $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - - foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) { - $featureProdRemoved->setProduct(null); - } - - $this->collFeatureProds = null; - foreach ($featureProds as $featureProd) { - $this->addFeatureProd($featureProd); - } - - $this->collFeatureProds = $featureProds; - $this->collFeatureProdsPartial = false; - } - - /** - * Returns the number of related FeatureProd objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureProd objects. - * @throws PropelException - */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. - * - * @param FeatureProd $l FeatureProd - * @return Product The current object (for fluent API support) - */ - public function addFeatureProd(FeatureProd $l) - { - if ($this->collFeatureProds === null) { - $this->initFeatureProds(); - $this->collFeatureProdsPartial = true; - } - if (!$this->collFeatureProds->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddFeatureProd($l); - } - - return $this; - } - - /** - * @param FeatureProd $featureProd The featureProd object to add. - */ - protected function doAddFeatureProd($featureProd) - { - $this->collFeatureProds[]= $featureProd; - $featureProd->setProduct($this); - } - - /** - * @param FeatureProd $featureProd The featureProd object to remove. - */ - public function removeFeatureProd($featureProd) - { - if ($this->getFeatureProds()->contains($featureProd)) { - $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); - if (null === $this->featureProdsScheduledForDeletion) { - $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; - $this->featureProdsScheduledForDeletion->clear(); - } - $this->featureProdsScheduledForDeletion[]= $featureProd; - $featureProd->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - /** - * Clears out the collImages collection - * - * 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 - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - } - - /** - * reset is the collImages collection loaded partially - * - * @return void - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); - } - - /** - * Gets an array of Image objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Image[] List of Image objects - * @throws PropelException - */ - public function getImages($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ImageQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - return $collImages; - } - - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $images A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setImages(PropelCollection $images, PropelPDO $con = null) - { - $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images); - - foreach ($this->imagesScheduledForDeletion as $imageRemoved) { - $imageRemoved->setProduct(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. - * - * @param Image $l Image - * @return Product The current object (for fluent API support) - */ - public function addImage(Image $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - if (!$this->collImages->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setProduct($this); - } - - /** - * @param Image $image The image object to remove. - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collProductCategorys collection - * - * 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 - * @see addProductCategorys() - */ - public function clearProductCategorys() - { - $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized - $this->collProductCategorysPartial = null; - } - - /** - * reset is the collProductCategorys collection loaded partially - * - * @return void - */ - public function resetPartialProductCategorys($v = true) - { - $this->collProductCategorysPartial = $v; - } - - /** - * Initializes the collProductCategorys collection. - * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initProductCategorys($overrideExisting = true) - { - if (null !== $this->collProductCategorys && !$overrideExisting) { - return; - } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); - } - - /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - * @throws PropelException - */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { - // return empty collection - $this->initProductCategorys(); - } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); - - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); - } - } - - $this->collProductCategorysPartial = true; - } - - return $collProductCategorys; - } - - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { - if($obj->isNew()) { - $collProductCategorys[] = $obj; - } - } - } - - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; - } - } - - return $this->collProductCategorys; - } - - /** - * Sets a collection of ProductCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $productCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) - { - $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); - - foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) { - $productCategoryRemoved->setProduct(null); - } - - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { - $this->addProductCategory($productCategory); - } - - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; - } - - /** - * Returns the number of related ProductCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ProductCategory objects. - * @throws PropelException - */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. - * - * @param ProductCategory $l ProductCategory - * @return Product The current object (for fluent API support) - */ - public function addProductCategory(ProductCategory $l) - { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; - } - if (!$this->collProductCategorys->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddProductCategory($l); - } - - return $this; - } - - /** - * @param ProductCategory $productCategory The productCategory object to add. - */ - protected function doAddProductCategory($productCategory) - { - $this->collProductCategorys[]= $productCategory; - $productCategory->setProduct($this); - } - - /** - * @param ProductCategory $productCategory The productCategory object to remove. - */ - public function removeProductCategory($productCategory) - { - if ($this->getProductCategorys()->contains($productCategory)) { - $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); - if (null === $this->productCategorysScheduledForDeletion) { - $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; - $this->productCategorysScheduledForDeletion->clear(); - } - $this->productCategorysScheduledForDeletion[]= $productCategory; - $productCategory->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ProductCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - */ - public function getProductCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ProductCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getProductCategorys($query, $con); - } - - /** - * Clears out the collProductDescs collection - * - * 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 - * @see addProductDescs() - */ - public function clearProductDescs() - { - $this->collProductDescs = null; // important to set this to null since that means it is uninitialized - $this->collProductDescsPartial = null; - } - - /** - * reset is the collProductDescs collection loaded partially - * - * @return void - */ - public function resetPartialProductDescs($v = true) - { - $this->collProductDescsPartial = $v; - } - - /** - * Initializes the collProductDescs collection. - * - * By default this just sets the collProductDescs collection to an empty array (like clearcollProductDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initProductDescs($overrideExisting = true) - { - if (null !== $this->collProductDescs && !$overrideExisting) { - return; - } - $this->collProductDescs = new PropelObjectCollection(); - $this->collProductDescs->setModel('ProductDesc'); - } - - /** - * Gets an array of ProductDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ProductDesc[] List of ProductDesc objects - * @throws PropelException - */ - public function getProductDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductDescsPartial && !$this->isNew(); - if (null === $this->collProductDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductDescs) { - // return empty collection - $this->initProductDescs(); - } else { - $collProductDescs = ProductDescQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductDescsPartial && count($collProductDescs)) { - $this->initProductDescs(false); - - foreach($collProductDescs as $obj) { - if (false == $this->collProductDescs->contains($obj)) { - $this->collProductDescs->append($obj); - } - } - - $this->collProductDescsPartial = true; - } - - return $collProductDescs; - } - - if($partial && $this->collProductDescs) { - foreach($this->collProductDescs as $obj) { - if($obj->isNew()) { - $collProductDescs[] = $obj; - } - } - } - - $this->collProductDescs = $collProductDescs; - $this->collProductDescsPartial = false; - } - } - - return $this->collProductDescs; - } - - /** - * Sets a collection of ProductDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $productDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setProductDescs(PropelCollection $productDescs, PropelPDO $con = null) - { - $this->productDescsScheduledForDeletion = $this->getProductDescs(new Criteria(), $con)->diff($productDescs); - - foreach ($this->productDescsScheduledForDeletion as $productDescRemoved) { - $productDescRemoved->setProduct(null); - } - - $this->collProductDescs = null; - foreach ($productDescs as $productDesc) { - $this->addProductDesc($productDesc); - } - - $this->collProductDescs = $productDescs; - $this->collProductDescsPartial = false; - } - - /** - * Returns the number of related ProductDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ProductDesc objects. - * @throws PropelException - */ - public function countProductDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductDescsPartial && !$this->isNew(); - if (null === $this->collProductDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getProductDescs()); - } - $query = ProductDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - } else { - return count($this->collProductDescs); - } - } - - /** - * Method called to associate a ProductDesc object to this object - * through the ProductDesc foreign key attribute. - * - * @param ProductDesc $l ProductDesc - * @return Product The current object (for fluent API support) - */ - public function addProductDesc(ProductDesc $l) - { - if ($this->collProductDescs === null) { - $this->initProductDescs(); - $this->collProductDescsPartial = true; - } - if (!$this->collProductDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddProductDesc($l); - } - - return $this; - } - - /** - * @param ProductDesc $productDesc The productDesc object to add. - */ - protected function doAddProductDesc($productDesc) - { - $this->collProductDescs[]= $productDesc; - $productDesc->setProduct($this); - } - - /** - * @param ProductDesc $productDesc The productDesc object to remove. - */ - public function removeProductDesc($productDesc) - { - if ($this->getProductDescs()->contains($productDesc)) { - $this->collProductDescs->remove($this->collProductDescs->search($productDesc)); - if (null === $this->productDescsScheduledForDeletion) { - $this->productDescsScheduledForDeletion = clone $this->collProductDescs; - $this->productDescsScheduledForDeletion->clear(); - } - $this->productDescsScheduledForDeletion[]= $productDesc; - $productDesc->setProduct(null); - } - } - /** * Clears out the collRewritings collection * @@ -4387,238 +4630,6 @@ abstract class BaseProduct extends BaseObject implements Persistent return $this->getRewritings($query, $con); } - /** - * Clears out the collStocks collection - * - * 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 - * @see addStocks() - */ - public function clearStocks() - { - $this->collStocks = null; // important to set this to null since that means it is uninitialized - $this->collStocksPartial = null; - } - - /** - * reset is the collStocks collection loaded partially - * - * @return void - */ - public function resetPartialStocks($v = true) - { - $this->collStocksPartial = $v; - } - - /** - * Initializes the collStocks collection. - * - * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initStocks($overrideExisting = true) - { - if (null !== $this->collStocks && !$overrideExisting) { - return; - } - $this->collStocks = new PropelObjectCollection(); - $this->collStocks->setModel('Stock'); - } - - /** - * Gets an array of Stock objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Stock[] List of Stock objects - * @throws PropelException - */ - public function getStocks($criteria = null, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - // return empty collection - $this->initStocks(); - } else { - $collStocks = StockQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); - - foreach($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); - } - } - - $this->collStocksPartial = true; - } - - return $collStocks; - } - - if($partial && $this->collStocks) { - foreach($this->collStocks as $obj) { - if($obj->isNew()) { - $collStocks[] = $obj; - } - } - } - - $this->collStocks = $collStocks; - $this->collStocksPartial = false; - } - } - - return $this->collStocks; - } - - /** - * Sets a collection of Stock objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $stocks A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setStocks(PropelCollection $stocks, PropelPDO $con = null) - { - $this->stocksScheduledForDeletion = $this->getStocks(new Criteria(), $con)->diff($stocks); - - foreach ($this->stocksScheduledForDeletion as $stockRemoved) { - $stockRemoved->setProduct(null); - } - - $this->collStocks = null; - foreach ($stocks as $stock) { - $this->addStock($stock); - } - - $this->collStocks = $stocks; - $this->collStocksPartial = false; - } - - /** - * Returns the number of related Stock objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Stock objects. - * @throws PropelException - */ - public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - 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); - } - } - - /** - * Method called to associate a Stock object to this object - * through the Stock foreign key attribute. - * - * @param Stock $l Stock - * @return Product The current object (for fluent API support) - */ - public function addStock(Stock $l) - { - if ($this->collStocks === null) { - $this->initStocks(); - $this->collStocksPartial = true; - } - if (!$this->collStocks->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddStock($l); - } - - return $this; - } - - /** - * @param Stock $stock The stock object to add. - */ - protected function doAddStock($stock) - { - $this->collStocks[]= $stock; - $stock->setProduct($this); - } - - /** - * @param Stock $stock The stock object to remove. - */ - public function removeStock($stock) - { - if ($this->getStocks()->contains($stock)) { - $this->collStocks->remove($this->collStocks->search($stock)); - if (null === $this->stocksScheduledForDeletion) { - $this->stocksScheduledForDeletion = clone $this->collStocks; - $this->stocksScheduledForDeletion->clear(); - } - $this->stocksScheduledForDeletion[]= $stock; - $stock->setProduct(null); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Stocks from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Stock[] List of Stock objects - */ - public function getStocksJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = StockQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); - - return $this->getStocks($query, $con); - } - /** * Clears the current object and sets all attributes to their default values */ @@ -4632,7 +4643,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->ecotax = null; $this->newness = null; $this->promo = null; - $this->quantity = null; + $this->stock = null; $this->visible = null; $this->weight = null; $this->position = null; @@ -4659,6 +4670,41 @@ abstract class BaseProduct extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collProductDescs) { + foreach ($this->collProductDescs as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collProductCategorys) { + foreach ($this->collProductCategorys as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collFeatureProds) { + foreach ($this->collFeatureProds as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collStocks) { + foreach ($this->collStocks as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collContentAssocs) { + foreach ($this->collContentAssocs as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collImages) { + foreach ($this->collImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collDocuments) { + foreach ($this->collDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collAccessorysRelatedByProductId) { foreach ($this->collAccessorysRelatedByProductId as $o) { $o->clearAllReferences($deep); @@ -4669,48 +4715,41 @@ abstract class BaseProduct extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureProds) { - foreach ($this->collFeatureProds as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductCategorys) { - foreach ($this->collProductCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductDescs) { - foreach ($this->collProductDescs as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); } } - if ($this->collStocks) { - foreach ($this->collStocks as $o) { - $o->clearAllReferences($deep); - } - } } // if ($deep) + if ($this->collProductDescs instanceof PropelCollection) { + $this->collProductDescs->clearIterator(); + } + $this->collProductDescs = null; + if ($this->collProductCategorys instanceof PropelCollection) { + $this->collProductCategorys->clearIterator(); + } + $this->collProductCategorys = null; + if ($this->collFeatureProds instanceof PropelCollection) { + $this->collFeatureProds->clearIterator(); + } + $this->collFeatureProds = null; + if ($this->collStocks instanceof PropelCollection) { + $this->collStocks->clearIterator(); + } + $this->collStocks = null; + if ($this->collContentAssocs instanceof PropelCollection) { + $this->collContentAssocs->clearIterator(); + } + $this->collContentAssocs = null; + if ($this->collImages instanceof PropelCollection) { + $this->collImages->clearIterator(); + } + $this->collImages = null; + if ($this->collDocuments instanceof PropelCollection) { + $this->collDocuments->clearIterator(); + } + $this->collDocuments = null; if ($this->collAccessorysRelatedByProductId instanceof PropelCollection) { $this->collAccessorysRelatedByProductId->clearIterator(); } @@ -4719,38 +4758,10 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collAccessorysRelatedByAccessory->clearIterator(); } $this->collAccessorysRelatedByAccessory = null; - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collFeatureProds instanceof PropelCollection) { - $this->collFeatureProds->clearIterator(); - } - $this->collFeatureProds = null; - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collProductCategorys instanceof PropelCollection) { - $this->collProductCategorys->clearIterator(); - } - $this->collProductCategorys = null; - if ($this->collProductDescs instanceof PropelCollection) { - $this->collProductDescs->clearIterator(); - } - $this->collProductDescs = null; if ($this->collRewritings instanceof PropelCollection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; - if ($this->collStocks instanceof PropelCollection) { - $this->collStocks->clearIterator(); - } - $this->collStocks = null; $this->aTaxRule = null; } @@ -4774,4 +4785,18 @@ abstract class BaseProduct extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Product The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseProductCategory.php b/core/lib/Thelia/Model/om/BaseProductCategory.php index 8814b09b1..7f07dce2b 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategory.php +++ b/core/lib/Thelia/Model/om/BaseProductCategory.php @@ -5,10 +5,12 @@ namespace Thelia\Model\om; use \BaseObject; use \BasePeer; use \Criteria; +use \DateTime; use \Exception; use \PDO; use \Persistent; use \Propel; +use \PropelDateTime; use \PropelException; use \PropelPDO; use Thelia\Model\Category; @@ -59,6 +61,18 @@ abstract class BaseProductCategory extends BaseObject implements Persistent */ protected $category_id; + /** + * The value for the created_at field. + * @var string + */ + protected $created_at; + + /** + * The value for the updated_at field. + * @var string + */ + protected $updated_at; + /** * @var Product */ @@ -103,6 +117,80 @@ abstract class BaseProductCategory extends BaseObject implements Persistent return $this->category_id; } + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + if ($this->created_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + if ($this->updated_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } + } + /** * Set the value of [product_id] column. * @@ -153,6 +241,52 @@ abstract class BaseProductCategory extends BaseObject implements Persistent return $this; } // setCategoryId() + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return ProductCategory The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = ProductCategoryPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return ProductCategory The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = ProductCategoryPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + /** * Indicates whether the columns in this object are only set to default values. * @@ -187,6 +321,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $this->product_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->resetModified(); $this->setNew(false); @@ -195,7 +331,7 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 2; // 2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS. + return $startcol + 4; // 4 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating ProductCategory object", $e); @@ -337,8 +473,19 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductCategoryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -436,6 +583,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) { $modifiedColumns[':p' . $index++] = '`CATEGORY_ID`'; } + if ($this->isColumnModified(ProductCategoryPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; + } + if ($this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; + } $sql = sprintf( 'INSERT INTO `product_category` (%s) VALUES (%s)', @@ -453,6 +606,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent case '`CATEGORY_ID`': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; + case '`CREATED_AT`': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '`UPDATED_AT`': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; } } $stmt->execute(); @@ -604,6 +763,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent case 1: return $this->getCategoryId(); break; + case 2: + return $this->getCreatedAt(); + break; + case 3: + return $this->getUpdatedAt(); + break; default: return null; break; @@ -635,6 +800,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent $result = array( $keys[0] => $this->getProductId(), $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { if (null !== $this->aProduct) { @@ -683,6 +850,12 @@ abstract class BaseProductCategory extends BaseObject implements Persistent case 1: $this->setCategoryId($value); break; + case 2: + $this->setCreatedAt($value); + break; + case 3: + $this->setUpdatedAt($value); + break; } // switch() } @@ -709,6 +882,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); } /** @@ -722,6 +897,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) $criteria->add(ProductCategoryPeer::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) $criteria->add(ProductCategoryPeer::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ProductCategoryPeer::CREATED_AT)) $criteria->add(ProductCategoryPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) $criteria->add(ProductCategoryPeer::UPDATED_AT, $this->updated_at); return $criteria; } @@ -794,6 +971,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent { $copyObj->setProductId($this->getProductId()); $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -960,6 +1139,8 @@ abstract class BaseProductCategory extends BaseObject implements Persistent { $this->product_id = null; $this->category_id = null; + $this->created_at = null; + $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); @@ -1006,4 +1187,18 @@ abstract class BaseProductCategory extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ProductCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductCategoryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php index e3a614cee..b5b899fe9 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php @@ -38,13 +38,13 @@ abstract class BaseProductCategoryPeer const TM_CLASS = 'ProductCategoryTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 2; + const NUM_COLUMNS = 4; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 2; + const NUM_HYDRATE_COLUMNS = 4; /** the column name for the PRODUCT_ID field */ const PRODUCT_ID = 'product_category.PRODUCT_ID'; @@ -52,6 +52,12 @@ abstract class BaseProductCategoryPeer /** 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 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'; @@ -71,12 +77,12 @@ abstract class BaseProductCategoryPeer * e.g. ProductCategoryPeer::$fieldNames[ProductCategoryPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('ProductId', 'CategoryId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('productId', 'categoryId', ), - BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID, ProductCategoryPeer::CATEGORY_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID', 'CATEGORY_ID', ), - BasePeer::TYPE_FIELDNAME => array ('product_id', 'category_id', ), - BasePeer::TYPE_NUM => array (0, 1, ) + BasePeer::TYPE_PHPNAME => array ('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('productId', 'categoryId', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID, ProductCategoryPeer::CATEGORY_ID, ProductCategoryPeer::CREATED_AT, ProductCategoryPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('product_id', 'category_id', 'created_at', 'updated_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) ); /** @@ -86,12 +92,12 @@ abstract class BaseProductCategoryPeer * e.g. ProductCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('ProductId' => 0, 'CategoryId' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('productId' => 0, 'categoryId' => 1, ), - BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID => 0, ProductCategoryPeer::CATEGORY_ID => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('product_id' => 0, 'category_id' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) + BasePeer::TYPE_PHPNAME => array ('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID => 0, ProductCategoryPeer::CATEGORY_ID => 1, ProductCategoryPeer::CREATED_AT => 2, ProductCategoryPeer::UPDATED_AT => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) ); /** @@ -167,9 +173,13 @@ abstract class BaseProductCategoryPeer if (null === $alias) { $criteria->addSelectColumn(ProductCategoryPeer::PRODUCT_ID); $criteria->addSelectColumn(ProductCategoryPeer::CATEGORY_ID); + $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'); } } diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php index 13124bde2..92dd1ebfa 100644 --- a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php @@ -25,9 +25,13 @@ use Thelia\Model\ProductCategoryQuery; * * @method ProductCategoryQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ProductCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column + * @method ProductCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ProductCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ProductCategoryQuery groupByProductId() Group by the product_id column * @method ProductCategoryQuery groupByCategoryId() Group by the category_id column + * @method ProductCategoryQuery groupByCreatedAt() Group by the created_at column + * @method ProductCategoryQuery groupByUpdatedAt() Group by the updated_at column * * @method ProductCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ProductCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -46,9 +50,13 @@ use Thelia\Model\ProductCategoryQuery; * * @method ProductCategory findOneByProductId(int $product_id) Return the first ProductCategory filtered by the product_id column * @method ProductCategory findOneByCategoryId(int $category_id) Return the first ProductCategory filtered by the category_id column + * @method ProductCategory findOneByCreatedAt(string $created_at) Return the first ProductCategory filtered by the created_at column + * @method ProductCategory findOneByUpdatedAt(string $updated_at) Return the first ProductCategory filtered by the updated_at column * * @method array findByProductId(int $product_id) Return ProductCategory objects filtered by the product_id column * @method array findByCategoryId(int $category_id) Return ProductCategory objects filtered by the category_id column + * @method array findByCreatedAt(string $created_at) Return ProductCategory objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ProductCategory objects filtered by the updated_at column * * @package propel.generator.Thelia.Model.om */ @@ -139,7 +147,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `PRODUCT_ID`, `CATEGORY_ID` 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); @@ -298,6 +306,92 @@ abstract class BaseProductCategoryQuery extends ModelCriteria return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison); } + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt, $comparison); + } + /** * Filter the query by a related Product object * @@ -468,4 +562,69 @@ abstract class BaseProductCategoryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductCategoryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductCategoryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductCategoryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ProductCategoryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductCategoryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseProductDesc.php b/core/lib/Thelia/Model/om/BaseProductDesc.php index 220311ec5..b8563d4d6 100644 --- a/core/lib/Thelia/Model/om/BaseProductDesc.php +++ b/core/lib/Thelia/Model/om/BaseProductDesc.php @@ -96,10 +96,10 @@ abstract class BaseProductDesc extends BaseObject implements Persistent protected $created_at; /** - * The value for the updatet_at field. + * The value for the updated_at field. * @var string */ - protected $updatet_at; + protected $updated_at; /** * @var Product @@ -228,13 +228,40 @@ abstract class BaseProductDesc extends BaseObject implements Persistent } /** - * Get the [updatet_at] column value. + * Get the [optionally formatted] temporal [updated_at] column value. * - * @return string + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is null, then the raw DateTime object will be returned. + * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 + * @throws PropelException - if unable to parse/validate the date/time value. */ - public function getUpdatetAt() + public function getUpdatedAt($format = 'Y-m-d H:i:s') { - return $this->updatet_at; + if ($this->updated_at === null) { + return null; + } + + if ($this->updated_at === '0000-00-00 00:00:00') { + // 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); + } + } + + 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); + } } /** @@ -412,25 +439,27 @@ abstract class BaseProductDesc extends BaseObject implements Persistent } // setCreatedAt() /** - * Set the value of [updatet_at] column. + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. * - * @param string $v new value + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. * @return ProductDesc The current object (for fluent API support) */ - public function setUpdatetAt($v) + public function setUpdatedAt($v) { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->updatet_at !== $v) { - $this->updatet_at = $v; - $this->modifiedColumns[] = ProductDescPeer::UPDATET_AT; - } + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = ProductDescPeer::UPDATED_AT; + } + } // if either are not null return $this; - } // setUpdatetAt() + } // setUpdatedAt() /** * Indicates whether the columns in this object are only set to default values. @@ -472,7 +501,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->postscriptum = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->updatet_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->resetModified(); $this->setNew(false); @@ -619,8 +648,19 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -733,8 +773,8 @@ abstract class BaseProductDesc extends BaseObject implements Persistent if ($this->isColumnModified(ProductDescPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; } - if ($this->isColumnModified(ProductDescPeer::UPDATET_AT)) { - $modifiedColumns[':p' . $index++] = '`UPDATET_AT`'; + if ($this->isColumnModified(ProductDescPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; } $sql = sprintf( @@ -771,8 +811,8 @@ abstract class BaseProductDesc extends BaseObject implements Persistent case '`CREATED_AT`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; - case '`UPDATET_AT`': - $stmt->bindValue($identifier, $this->updatet_at, PDO::PARAM_STR); + case '`UPDATED_AT`': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; } } @@ -945,7 +985,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent return $this->getCreatedAt(); break; case 8: - return $this->getUpdatetAt(); + return $this->getUpdatedAt(); break; default: return null; @@ -984,7 +1024,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $keys[5] => $this->getChapo(), $keys[6] => $this->getPostscriptum(), $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatetAt(), + $keys[8] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { if (null !== $this->aProduct) { @@ -1049,7 +1089,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $this->setCreatedAt($value); break; case 8: - $this->setUpdatetAt($value); + $this->setUpdatedAt($value); break; } // switch() } @@ -1083,7 +1123,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setPostscriptum($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatetAt($arr[$keys[8]]); + if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); } /** @@ -1103,7 +1143,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent if ($this->isColumnModified(ProductDescPeer::CHAPO)) $criteria->add(ProductDescPeer::CHAPO, $this->chapo); if ($this->isColumnModified(ProductDescPeer::POSTSCRIPTUM)) $criteria->add(ProductDescPeer::POSTSCRIPTUM, $this->postscriptum); if ($this->isColumnModified(ProductDescPeer::CREATED_AT)) $criteria->add(ProductDescPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ProductDescPeer::UPDATET_AT)) $criteria->add(ProductDescPeer::UPDATET_AT, $this->updatet_at); + if ($this->isColumnModified(ProductDescPeer::UPDATED_AT)) $criteria->add(ProductDescPeer::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1174,7 +1214,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $copyObj->setChapo($this->getChapo()); $copyObj->setPostscriptum($this->getPostscriptum()); $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatetAt($this->getUpdatetAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of @@ -1297,7 +1337,7 @@ abstract class BaseProductDesc extends BaseObject implements Persistent $this->chapo = null; $this->postscriptum = null; $this->created_at = null; - $this->updatet_at = null; + $this->updated_at = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->clearAllReferences(); @@ -1343,4 +1383,18 @@ abstract class BaseProductDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ProductDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseProductDescPeer.php b/core/lib/Thelia/Model/om/BaseProductDescPeer.php index dfa73efe9..6c76dfd28 100644 --- a/core/lib/Thelia/Model/om/BaseProductDescPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductDescPeer.php @@ -69,8 +69,8 @@ abstract class BaseProductDescPeer /** the column name for the CREATED_AT field */ const CREATED_AT = 'product_desc.CREATED_AT'; - /** the column name for the UPDATET_AT field */ - const UPDATET_AT = 'product_desc.UPDATET_AT'; + /** the column name for the UPDATED_AT field */ + const UPDATED_AT = 'product_desc.UPDATED_AT'; /** The default string format for model objects of the related table **/ const DEFAULT_STRING_FORMAT = 'YAML'; @@ -91,11 +91,11 @@ abstract class BaseProductDescPeer * e.g. ProductDescPeer::$fieldNames[ProductDescPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'ProductId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatetAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatetAt', ), - BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID, ProductDescPeer::PRODUCT_ID, ProductDescPeer::LANG, ProductDescPeer::TITLE, ProductDescPeer::DESCRIPTION, ProductDescPeer::CHAPO, ProductDescPeer::POSTSCRIPTUM, ProductDescPeer::CREATED_AT, ProductDescPeer::UPDATET_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATET_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updatet_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'ProductId', 'Lang', 'Title', 'Description', 'Chapo', 'Postscriptum', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID, ProductDescPeer::PRODUCT_ID, ProductDescPeer::LANG, ProductDescPeer::TITLE, ProductDescPeer::DESCRIPTION, ProductDescPeer::CHAPO, ProductDescPeer::POSTSCRIPTUM, ProductDescPeer::CREATED_AT, ProductDescPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'LANG', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'lang', 'title', 'description', 'chapo', 'postscriptum', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); @@ -106,11 +106,11 @@ abstract class BaseProductDescPeer * e.g. ProductDescPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatetAt' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatetAt' => 8, ), - BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID => 0, ProductDescPeer::PRODUCT_ID => 1, ProductDescPeer::LANG => 2, ProductDescPeer::TITLE => 3, ProductDescPeer::DESCRIPTION => 4, ProductDescPeer::CHAPO => 5, ProductDescPeer::POSTSCRIPTUM => 6, ProductDescPeer::CREATED_AT => 7, ProductDescPeer::UPDATET_AT => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATET_AT' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updatet_at' => 8, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Lang' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Postscriptum' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), + BasePeer::TYPE_COLNAME => array (ProductDescPeer::ID => 0, ProductDescPeer::PRODUCT_ID => 1, ProductDescPeer::LANG => 2, ProductDescPeer::TITLE => 3, ProductDescPeer::DESCRIPTION => 4, ProductDescPeer::CHAPO => 5, ProductDescPeer::POSTSCRIPTUM => 6, ProductDescPeer::CREATED_AT => 7, ProductDescPeer::UPDATED_AT => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'LANG' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'POSTSCRIPTUM' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'lang' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'postscriptum' => 6, 'created_at' => 7, 'updated_at' => 8, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); @@ -193,7 +193,7 @@ abstract class BaseProductDescPeer $criteria->addSelectColumn(ProductDescPeer::CHAPO); $criteria->addSelectColumn(ProductDescPeer::POSTSCRIPTUM); $criteria->addSelectColumn(ProductDescPeer::CREATED_AT); - $criteria->addSelectColumn(ProductDescPeer::UPDATET_AT); + $criteria->addSelectColumn(ProductDescPeer::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PRODUCT_ID'); @@ -203,7 +203,7 @@ abstract class BaseProductDescPeer $criteria->addSelectColumn($alias . '.CHAPO'); $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATET_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); } } diff --git a/core/lib/Thelia/Model/om/BaseProductDescQuery.php b/core/lib/Thelia/Model/om/BaseProductDescQuery.php index bd0ecad55..2fc764d64 100644 --- a/core/lib/Thelia/Model/om/BaseProductDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductDescQuery.php @@ -30,7 +30,7 @@ use Thelia\Model\ProductDescQuery; * @method ProductDescQuery orderByChapo($order = Criteria::ASC) Order by the chapo column * @method ProductDescQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * @method ProductDescQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ProductDescQuery orderByUpdatetAt($order = Criteria::ASC) Order by the updatet_at column + * @method ProductDescQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ProductDescQuery groupById() Group by the id column * @method ProductDescQuery groupByProductId() Group by the product_id column @@ -40,7 +40,7 @@ use Thelia\Model\ProductDescQuery; * @method ProductDescQuery groupByChapo() Group by the chapo column * @method ProductDescQuery groupByPostscriptum() Group by the postscriptum column * @method ProductDescQuery groupByCreatedAt() Group by the created_at column - * @method ProductDescQuery groupByUpdatetAt() Group by the updatet_at column + * @method ProductDescQuery groupByUpdatedAt() Group by the updated_at column * * @method ProductDescQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ProductDescQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query @@ -61,7 +61,7 @@ use Thelia\Model\ProductDescQuery; * @method ProductDesc findOneByChapo(string $chapo) Return the first ProductDesc filtered by the chapo column * @method ProductDesc findOneByPostscriptum(string $postscriptum) Return the first ProductDesc filtered by the postscriptum column * @method ProductDesc findOneByCreatedAt(string $created_at) Return the first ProductDesc filtered by the created_at column - * @method ProductDesc findOneByUpdatetAt(string $updatet_at) Return the first ProductDesc filtered by the updatet_at column + * @method ProductDesc findOneByUpdatedAt(string $updated_at) Return the first ProductDesc filtered by the updated_at column * * @method array findById(int $id) Return ProductDesc objects filtered by the id column * @method array findByProductId(int $product_id) Return ProductDesc objects filtered by the product_id column @@ -71,7 +71,7 @@ use Thelia\Model\ProductDescQuery; * @method array findByChapo(string $chapo) Return ProductDesc objects filtered by the chapo column * @method array findByPostscriptum(string $postscriptum) Return ProductDesc objects filtered by the postscriptum column * @method array findByCreatedAt(string $created_at) Return ProductDesc objects filtered by the created_at column - * @method array findByUpdatetAt(string $updatet_at) Return ProductDesc objects filtered by the updatet_at column + * @method array findByUpdatedAt(string $updated_at) Return ProductDesc objects filtered by the updated_at column * * @package propel.generator.Thelia.Model.om */ @@ -161,7 +161,7 @@ abstract class BaseProductDescQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `PRODUCT_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATET_AT` FROM `product_desc` WHERE `ID` = :p0'; + $sql = 'SELECT `ID`, `PRODUCT_ID`, `LANG`, `TITLE`, `DESCRIPTION`, `CHAPO`, `POSTSCRIPTUM`, `CREATED_AT`, `UPDATED_AT` FROM `product_desc` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -509,32 +509,46 @@ abstract class BaseProductDescQuery extends ModelCriteria } /** - * Filter the query on the updatet_at column + * Filter the query on the updated_at column * * Example usage: * - * $query->filterByUpdatetAt('fooValue'); // WHERE updatet_at = 'fooValue' - * $query->filterByUpdatetAt('%fooValue%'); // WHERE updatet_at LIKE '%fooValue%' + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' * * - * @param string $updatetAt The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ProductDescQuery The current query, for fluid interface */ - public function filterByUpdatetAt($updatetAt = null, $comparison = null) + public function filterByUpdatedAt($updatedAt = null, $comparison = null) { - if (null === $comparison) { - if (is_array($updatetAt)) { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProductDescPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProductDescPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $updatetAt)) { - $updatetAt = str_replace('*', '%', $updatetAt); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(ProductDescPeer::UPDATET_AT, $updatetAt, $comparison); + return $this->addUsingAlias(ProductDescPeer::UPDATED_AT, $updatedAt, $comparison); } /** @@ -629,4 +643,69 @@ abstract class BaseProductDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ProductDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php index 52b5aaaf3..c3ee0bbcc 100644 --- a/core/lib/Thelia/Model/om/BaseProductPeer.php +++ b/core/lib/Thelia/Model/om/BaseProductPeer.php @@ -78,8 +78,8 @@ abstract class BaseProductPeer /** the column name for the PROMO field */ const PROMO = 'product.PROMO'; - /** the column name for the QUANTITY field */ - const QUANTITY = 'product.QUANTITY'; + /** the column name for the STOCK field */ + const STOCK = 'product.STOCK'; /** the column name for the VISIBLE field */ const VISIBLE = 'product.VISIBLE'; @@ -115,11 +115,11 @@ abstract class BaseProductPeer * e.g. ProductPeer::$fieldNames[ProductPeer::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ProductPeer::ID, ProductPeer::TAX_RULE_ID, ProductPeer::REF, ProductPeer::PRICE, ProductPeer::PRICE2, ProductPeer::ECOTAX, ProductPeer::NEWNESS, ProductPeer::PROMO, ProductPeer::QUANTITY, ProductPeer::VISIBLE, ProductPeer::WEIGHT, ProductPeer::POSITION, ProductPeer::CREATED_AT, ProductPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'QUANTITY', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'created_at', 'updated_at', ), + BasePeer::TYPE_PHPNAME => array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Stock', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (ProductPeer::ID, ProductPeer::TAX_RULE_ID, ProductPeer::REF, ProductPeer::PRICE, ProductPeer::PRICE2, ProductPeer::ECOTAX, ProductPeer::NEWNESS, ProductPeer::PROMO, ProductPeer::STOCK, ProductPeer::VISIBLE, ProductPeer::WEIGHT, ProductPeer::POSITION, ProductPeer::CREATED_AT, ProductPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'STOCK', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'stock', 'visible', 'weight', 'position', 'created_at', 'updated_at', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); @@ -130,11 +130,11 @@ abstract class BaseProductPeer * e.g. ProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Quantity' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), - BasePeer::TYPE_COLNAME => array (ProductPeer::ID => 0, ProductPeer::TAX_RULE_ID => 1, ProductPeer::REF => 2, ProductPeer::PRICE => 3, ProductPeer::PRICE2 => 4, ProductPeer::ECOTAX => 5, ProductPeer::NEWNESS => 6, ProductPeer::PROMO => 7, ProductPeer::QUANTITY => 8, ProductPeer::VISIBLE => 9, ProductPeer::WEIGHT => 10, ProductPeer::POSITION => 11, ProductPeer::CREATED_AT => 12, ProductPeer::UPDATED_AT => 13, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'QUANTITY' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, ), + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Stock' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), + BasePeer::TYPE_COLNAME => array (ProductPeer::ID => 0, ProductPeer::TAX_RULE_ID => 1, ProductPeer::REF => 2, ProductPeer::PRICE => 3, ProductPeer::PRICE2 => 4, ProductPeer::ECOTAX => 5, ProductPeer::NEWNESS => 6, ProductPeer::PROMO => 7, ProductPeer::STOCK => 8, ProductPeer::VISIBLE => 9, ProductPeer::WEIGHT => 10, ProductPeer::POSITION => 11, ProductPeer::CREATED_AT => 12, ProductPeer::UPDATED_AT => 13, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'STOCK' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'stock' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) ); @@ -217,7 +217,7 @@ abstract class BaseProductPeer $criteria->addSelectColumn(ProductPeer::ECOTAX); $criteria->addSelectColumn(ProductPeer::NEWNESS); $criteria->addSelectColumn(ProductPeer::PROMO); - $criteria->addSelectColumn(ProductPeer::QUANTITY); + $criteria->addSelectColumn(ProductPeer::STOCK); $criteria->addSelectColumn(ProductPeer::VISIBLE); $criteria->addSelectColumn(ProductPeer::WEIGHT); $criteria->addSelectColumn(ProductPeer::POSITION); @@ -232,7 +232,7 @@ abstract class BaseProductPeer $criteria->addSelectColumn($alias . '.ECOTAX'); $criteria->addSelectColumn($alias . '.NEWNESS'); $criteria->addSelectColumn($alias . '.PROMO'); - $criteria->addSelectColumn($alias . '.QUANTITY'); + $criteria->addSelectColumn($alias . '.STOCK'); $criteria->addSelectColumn($alias . '.VISIBLE'); $criteria->addSelectColumn($alias . '.WEIGHT'); $criteria->addSelectColumn($alias . '.POSITION'); @@ -437,36 +437,36 @@ abstract class BaseProductPeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in AccessoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AccessoryPeer::clearInstancePool(); - // Invalidate objects in AccessoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AccessoryPeer::clearInstancePool(); - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in FeatureProdPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureProdPeer::clearInstancePool(); - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); - // Invalidate objects in ProductCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ProductCategoryPeer::clearInstancePool(); // Invalidate objects in ProductDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductDescPeer::clearInstancePool(); - // Invalidate objects in RewritingPeer instance pool, + // Invalidate objects in ProductCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingPeer::clearInstancePool(); + ProductCategoryPeer::clearInstancePool(); + // Invalidate objects in FeatureProdPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureProdPeer::clearInstancePool(); // Invalidate objects in StockPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. StockPeer::clearInstancePool(); + // Invalidate objects in ContentAssocPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentAssocPeer::clearInstancePool(); + // Invalidate objects in ImagePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ImagePeer::clearInstancePool(); + // Invalidate objects in DocumentPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + DocumentPeer::clearInstancePool(); + // Invalidate objects in AccessoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AccessoryPeer::clearInstancePool(); + // Invalidate objects in AccessoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AccessoryPeer::clearInstancePool(); + // Invalidate objects in RewritingPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + RewritingPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php index 0bd645f34..b60aef4c8 100644 --- a/core/lib/Thelia/Model/om/BaseProductQuery.php +++ b/core/lib/Thelia/Model/om/BaseProductQuery.php @@ -39,7 +39,7 @@ use Thelia\Model\TaxRule; * @method ProductQuery orderByEcotax($order = Criteria::ASC) Order by the ecotax column * @method ProductQuery orderByNewness($order = Criteria::ASC) Order by the newness column * @method ProductQuery orderByPromo($order = Criteria::ASC) Order by the promo column - * @method ProductQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column + * @method ProductQuery orderByStock($order = Criteria::ASC) Order by the stock column * @method ProductQuery orderByVisible($order = Criteria::ASC) Order by the visible column * @method ProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column * @method ProductQuery orderByPosition($order = Criteria::ASC) Order by the position column @@ -54,7 +54,7 @@ use Thelia\Model\TaxRule; * @method ProductQuery groupByEcotax() Group by the ecotax column * @method ProductQuery groupByNewness() Group by the newness column * @method ProductQuery groupByPromo() Group by the promo column - * @method ProductQuery groupByQuantity() Group by the quantity column + * @method ProductQuery groupByStock() Group by the stock column * @method ProductQuery groupByVisible() Group by the visible column * @method ProductQuery groupByWeight() Group by the weight column * @method ProductQuery groupByPosition() Group by the position column @@ -69,6 +69,34 @@ use Thelia\Model\TaxRule; * @method ProductQuery rightJoinTaxRule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRule relation * @method ProductQuery innerJoinTaxRule($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRule relation * + * @method ProductQuery leftJoinProductDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductDesc relation + * @method ProductQuery rightJoinProductDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductDesc relation + * @method ProductQuery innerJoinProductDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductDesc relation + * + * @method ProductQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation + * @method ProductQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation + * @method ProductQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation + * + * @method ProductQuery leftJoinFeatureProd($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureProd relation + * @method ProductQuery rightJoinFeatureProd($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProd relation + * @method ProductQuery innerJoinFeatureProd($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProd relation + * + * @method ProductQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation + * @method ProductQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation + * @method ProductQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation + * + * @method ProductQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation + * @method ProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation + * @method ProductQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation + * + * @method ProductQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation + * @method ProductQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation + * @method ProductQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation + * + * @method ProductQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation + * @method ProductQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation + * @method ProductQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * * @method ProductQuery leftJoinAccessoryRelatedByProductId($relationAlias = null) Adds a LEFT JOIN clause to the query using the AccessoryRelatedByProductId relation * @method ProductQuery rightJoinAccessoryRelatedByProductId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AccessoryRelatedByProductId relation * @method ProductQuery innerJoinAccessoryRelatedByProductId($relationAlias = null) Adds a INNER JOIN clause to the query using the AccessoryRelatedByProductId relation @@ -77,38 +105,10 @@ use Thelia\Model\TaxRule; * @method ProductQuery rightJoinAccessoryRelatedByAccessory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AccessoryRelatedByAccessory relation * @method ProductQuery innerJoinAccessoryRelatedByAccessory($relationAlias = null) Adds a INNER JOIN clause to the query using the AccessoryRelatedByAccessory relation * - * @method ProductQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation - * @method ProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation - * @method ProductQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation - * - * @method ProductQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ProductQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ProductQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation - * - * @method ProductQuery leftJoinFeatureProd($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureProd relation - * @method ProductQuery rightJoinFeatureProd($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProd relation - * @method ProductQuery innerJoinFeatureProd($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProd relation - * - * @method ProductQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ProductQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ProductQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation - * - * @method ProductQuery leftJoinProductCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductCategory relation - * @method ProductQuery rightJoinProductCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductCategory relation - * @method ProductQuery innerJoinProductCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductCategory relation - * - * @method ProductQuery leftJoinProductDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductDesc relation - * @method ProductQuery rightJoinProductDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductDesc relation - * @method ProductQuery innerJoinProductDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductDesc relation - * * @method ProductQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ProductQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ProductQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation * - * @method ProductQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation - * @method ProductQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation - * @method ProductQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation - * * @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 * @@ -120,7 +120,7 @@ use Thelia\Model\TaxRule; * @method Product findOneByEcotax(double $ecotax) Return the first Product filtered by the ecotax column * @method Product findOneByNewness(int $newness) Return the first Product filtered by the newness column * @method Product findOneByPromo(int $promo) Return the first Product filtered by the promo column - * @method Product findOneByQuantity(int $quantity) Return the first Product filtered by the quantity column + * @method Product findOneByStock(int $stock) Return the first Product filtered by the stock column * @method Product findOneByVisible(int $visible) Return the first Product filtered by the visible column * @method Product findOneByWeight(double $weight) Return the first Product filtered by the weight column * @method Product findOneByPosition(int $position) Return the first Product filtered by the position column @@ -135,7 +135,7 @@ use Thelia\Model\TaxRule; * @method array findByEcotax(double $ecotax) Return Product objects filtered by the ecotax column * @method array findByNewness(int $newness) Return Product objects filtered by the newness column * @method array findByPromo(int $promo) Return Product objects filtered by the promo column - * @method array findByQuantity(int $quantity) Return Product objects filtered by the quantity column + * @method array findByStock(int $stock) Return Product objects filtered by the stock column * @method array findByVisible(int $visible) Return Product objects filtered by the visible column * @method array findByWeight(double $weight) Return Product objects filtered by the weight column * @method array findByPosition(int $position) Return Product objects filtered by the position column @@ -230,7 +230,7 @@ abstract class BaseProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `ID`, `TAX_RULE_ID`, `REF`, `PRICE`, `PRICE2`, `ECOTAX`, `NEWNESS`, `PROMO`, `QUANTITY`, `VISIBLE`, `WEIGHT`, `POSITION`, `CREATED_AT`, `UPDATED_AT` 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` FROM `product` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -624,16 +624,16 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query on the quantity column + * Filter the query on the stock column * * Example usage: * - * $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->filterByStock(1234); // WHERE stock = 1234 + * $query->filterByStock(array(12, 34)); // WHERE stock IN (12, 34) + * $query->filterByStock(array('min' => 12)); // WHERE stock > 12 * * - * @param mixed $quantity The value to use as filter. + * @param mixed $stock The value to use as filter. * Use scalar values for equality. * Use array values for in_array() equivalent. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @@ -641,16 +641,16 @@ abstract class BaseProductQuery extends ModelCriteria * * @return ProductQuery The current query, for fluid interface */ - public function filterByQuantity($quantity = null, $comparison = null) + public function filterByStock($stock = null, $comparison = null) { - if (is_array($quantity)) { + if (is_array($stock)) { $useMinMax = false; - if (isset($quantity['min'])) { - $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); + if (isset($stock['min'])) { + $this->addUsingAlias(ProductPeer::STOCK, $stock['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($quantity['max'])) { - $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + if (isset($stock['max'])) { + $this->addUsingAlias(ProductPeer::STOCK, $stock['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -661,7 +661,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::QUANTITY, $quantity, $comparison); + return $this->addUsingAlias(ProductPeer::STOCK, $stock, $comparison); } /** @@ -949,6 +949,524 @@ abstract class BaseProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery'); } + /** + * Filter the query by a related ProductDesc object + * + * @param ProductDesc|PropelObjectCollection $productDesc 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. + */ + public function filterByProductDesc($productDesc, $comparison = null) + { + if ($productDesc instanceof ProductDesc) { + return $this + ->addUsingAlias(ProductPeer::ID, $productDesc->getProductId(), $comparison); + } elseif ($productDesc instanceof PropelObjectCollection) { + return $this + ->useProductDescQuery() + ->filterByPrimaryKeys($productDesc->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductDesc() only accepts arguments of type ProductDesc or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductDesc relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinProductDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductDesc'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductDesc'); + } + + return $this; + } + + /** + * Use the ProductDesc relation ProductDesc object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductDescQuery A secondary query class using the current class as primary query + */ + public function useProductDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductDesc($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductDesc', '\Thelia\Model\ProductDescQuery'); + } + + /** + * Filter the query by a related ProductCategory object + * + * @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. + */ + public function filterByProductCategory($productCategory, $comparison = null) + { + if ($productCategory instanceof ProductCategory) { + return $this + ->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison); + } elseif ($productCategory instanceof PropelObjectCollection) { + return $this + ->useProductCategoryQuery() + ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductCategory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductCategory'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductCategory'); + } + + return $this; + } + + /** + * Use the ProductCategory relation ProductCategory object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query + */ + public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProductCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); + } + + /** + * Filter the query by a related FeatureProd object + * + * @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. + */ + public function filterByFeatureProd($featureProd, $comparison = null) + { + if ($featureProd instanceof FeatureProd) { + return $this + ->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison); + } elseif ($featureProd instanceof PropelObjectCollection) { + return $this + ->useFeatureProdQuery() + ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the FeatureProd relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FeatureProd'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FeatureProd'); + } + + return $this; + } + + /** + * Use the FeatureProd relation FeatureProd object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query + */ + public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFeatureProd($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); + } + + /** + * Filter the query by a related Stock object + * + * @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. + */ + public function filterByStock($stock, $comparison = null) + { + if ($stock instanceof Stock) { + return $this + ->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison); + } elseif ($stock instanceof PropelObjectCollection) { + return $this + ->useStockQuery() + ->filterByPrimaryKeys($stock->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Stock relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Stock'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Stock'); + } + + return $this; + } + + /** + * Use the Stock relation Stock object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query + */ + public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinStock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); + } + + /** + * Filter the query by a related ContentAssoc object + * + * @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. + */ + public function filterByContentAssoc($contentAssoc, $comparison = null) + { + if ($contentAssoc instanceof ContentAssoc) { + return $this + ->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison); + } elseif ($contentAssoc instanceof PropelObjectCollection) { + return $this + ->useContentAssocQuery() + ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentAssoc relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentAssoc'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentAssoc'); + } + + return $this; + } + + /** + * Use the ContentAssoc relation ContentAssoc object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query + */ + public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinContentAssoc($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); + } + + /** + * Filter the query by a related Image object + * + * @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. + */ + public function filterByImage($image, $comparison = null) + { + if ($image instanceof Image) { + return $this + ->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison); + } elseif ($image instanceof PropelObjectCollection) { + return $this + ->useImageQuery() + ->filterByPrimaryKeys($image->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Image relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Image'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Image'); + } + + return $this; + } + + /** + * Use the Image relation Image object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query + */ + public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); + } + + /** + * Filter the query by a related Document object + * + * @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. + */ + public function filterByDocument($document, $comparison = null) + { + if ($document instanceof Document) { + return $this + ->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison); + } elseif ($document instanceof PropelObjectCollection) { + return $this + ->useDocumentQuery() + ->filterByPrimaryKeys($document->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Document relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ProductQuery The current query, for fluid interface + */ + public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Document'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Document'); + } + + return $this; + } + + /** + * Use the Document relation Document object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query + */ + public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + } + /** * Filter the query by a related Accessory object * @@ -1097,450 +1615,6 @@ abstract class BaseProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByAccessory', '\Thelia\Model\AccessoryQuery'); } - /** - * Filter the query by a related ContentAssoc object - * - * @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. - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof ContentAssoc) { - return $this - ->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - - /** - * Filter the query by a related Document object - * - * @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. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Filter the query by a related FeatureProd object - * - * @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. - */ - public function filterByFeatureProd($featureProd, $comparison = null) - { - if ($featureProd instanceof FeatureProd) { - return $this - ->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { - return $this - ->useFeatureProdQuery() - ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureProd relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureProd'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureProd'); - } - - return $this; - } - - /** - * Use the FeatureProd relation FeatureProd object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query - */ - public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureProd($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); - } - - /** - * Filter the query by a related Image object - * - * @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. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related ProductCategory object - * - * @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. - */ - public function filterByProductCategory($productCategory, $comparison = null) - { - if ($productCategory instanceof ProductCategory) { - return $this - ->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { - return $this - ->useProductCategoryQuery() - ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductCategory'); - } - - return $this; - } - - /** - * Use the ProductCategory relation ProductCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query - */ - public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); - } - - /** - * Filter the query by a related ProductDesc object - * - * @param ProductDesc|PropelObjectCollection $productDesc 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. - */ - public function filterByProductDesc($productDesc, $comparison = null) - { - if ($productDesc instanceof ProductDesc) { - return $this - ->addUsingAlias(ProductPeer::ID, $productDesc->getProductId(), $comparison); - } elseif ($productDesc instanceof PropelObjectCollection) { - return $this - ->useProductDescQuery() - ->filterByPrimaryKeys($productDesc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProductDesc() only accepts arguments of type ProductDesc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductDesc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinProductDesc($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductDesc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductDesc'); - } - - return $this; - } - - /** - * Use the ProductDesc relation ProductDesc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductDescQuery A secondary query class using the current class as primary query - */ - public function useProductDescQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductDesc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductDesc', '\Thelia\Model\ProductDescQuery'); - } - /** * Filter the query by a related Rewriting object * @@ -1615,80 +1689,6 @@ abstract class BaseProductQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); } - /** - * Filter the query by a related Stock object - * - * @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. - */ - public function filterByStock($stock, $comparison = null) - { - if ($stock instanceof Stock) { - return $this - ->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison); - } elseif ($stock instanceof PropelObjectCollection) { - return $this - ->useStockQuery() - ->filterByPrimaryKeys($stock->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Stock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Stock'); - } - - return $this; - } - - /** - * Use the Stock relation Stock object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query - */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); - } - /** * Exclude object from result * @@ -1705,4 +1705,69 @@ abstract class BaseProductQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ProductQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ProductQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ProductQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ProductQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/om/BaseResource.php index f6c844fb8..b22798bf6 100644 --- a/core/lib/Thelia/Model/om/BaseResource.php +++ b/core/lib/Thelia/Model/om/BaseResource.php @@ -75,18 +75,18 @@ abstract class BaseResource extends BaseObject implements Persistent */ protected $updated_at; - /** - * @var PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects. - */ - protected $collGroupResources; - protected $collGroupResourcesPartial; - /** * @var PropelObjectCollection|ResourceDesc[] Collection to store aggregation of ResourceDesc objects. */ protected $collResourceDescs; protected $collResourceDescsPartial; + /** + * @var PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects. + */ + protected $collGroupResources; + protected $collGroupResourcesPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -105,13 +105,13 @@ abstract class BaseResource extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $groupResourcesScheduledForDeletion = null; + protected $resourceDescsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $resourceDescsScheduledForDeletion = null; + protected $groupResourcesScheduledForDeletion = null; /** * Get the [id] column value. @@ -401,10 +401,10 @@ abstract class BaseResource extends BaseObject implements Persistent if ($deep) { // also de-associate any related objects? - $this->collGroupResources = null; - $this->collResourceDescs = null; + $this->collGroupResources = null; + } // if (deep) } @@ -477,8 +477,19 @@ abstract class BaseResource extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ResourcePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ResourcePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ResourcePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -529,23 +540,6 @@ abstract class BaseResource extends BaseObject implements Persistent $this->resetModified(); } - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupResourcesScheduledForDeletion = null; - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->resourceDescsScheduledForDeletion !== null) { if (!$this->resourceDescsScheduledForDeletion->isEmpty()) { ResourceDescQuery::create() @@ -563,6 +557,23 @@ abstract class BaseResource extends BaseObject implements Persistent } } + if ($this->groupResourcesScheduledForDeletion !== null) { + if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { + GroupResourceQuery::create() + ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->groupResourcesScheduledForDeletion = null; + } + } + + if ($this->collGroupResources !== null) { + foreach ($this->collGroupResources as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -723,16 +734,16 @@ abstract class BaseResource extends BaseObject implements Persistent } - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { + if ($this->collResourceDescs !== null) { + foreach ($this->collResourceDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collResourceDescs !== null) { - foreach ($this->collResourceDescs as $referrerFK) { + if ($this->collGroupResources !== null) { + foreach ($this->collGroupResources as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -821,12 +832,12 @@ abstract class BaseResource extends BaseObject implements Persistent $keys[3] => $this->getUpdatedAt(), ); if ($includeForeignObjects) { - if (null !== $this->collGroupResources) { - $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collResourceDescs) { $result['ResourceDescs'] = $this->collResourceDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collGroupResources) { + $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -990,18 +1001,18 @@ abstract class BaseResource extends BaseObject implements Persistent // store object hash to prevent cycle $this->startCopy = true; - foreach ($this->getGroupResources() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupResource($relObj->copy($deepCopy)); - } - } - foreach ($this->getResourceDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addResourceDesc($relObj->copy($deepCopy)); } } + foreach ($this->getGroupResources() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addGroupResource($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1063,11 +1074,218 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function initRelation($relationName) { + if ('ResourceDesc' == $relationName) { + $this->initResourceDescs(); + } if ('GroupResource' == $relationName) { $this->initGroupResources(); } - if ('ResourceDesc' == $relationName) { + } + + /** + * Clears out the collResourceDescs collection + * + * 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 + * @see addResourceDescs() + */ + public function clearResourceDescs() + { + $this->collResourceDescs = null; // important to set this to null since that means it is uninitialized + $this->collResourceDescsPartial = null; + } + + /** + * reset is the collResourceDescs collection loaded partially + * + * @return void + */ + public function resetPartialResourceDescs($v = true) + { + $this->collResourceDescsPartial = $v; + } + + /** + * Initializes the collResourceDescs collection. + * + * By default this just sets the collResourceDescs collection to an empty array (like clearcollResourceDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initResourceDescs($overrideExisting = true) + { + if (null !== $this->collResourceDescs && !$overrideExisting) { + return; + } + $this->collResourceDescs = new PropelObjectCollection(); + $this->collResourceDescs->setModel('ResourceDesc'); + } + + /** + * Gets an array of ResourceDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this Resource is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|ResourceDesc[] List of ResourceDesc objects + * @throws PropelException + */ + public function getResourceDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collResourceDescsPartial && !$this->isNew(); + if (null === $this->collResourceDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collResourceDescs) { + // return empty collection + $this->initResourceDescs(); + } else { + $collResourceDescs = ResourceDescQuery::create(null, $criteria) + ->filterByResource($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collResourceDescsPartial && count($collResourceDescs)) { + $this->initResourceDescs(false); + + foreach($collResourceDescs as $obj) { + if (false == $this->collResourceDescs->contains($obj)) { + $this->collResourceDescs->append($obj); + } + } + + $this->collResourceDescsPartial = true; + } + + return $collResourceDescs; + } + + if($partial && $this->collResourceDescs) { + foreach($this->collResourceDescs as $obj) { + if($obj->isNew()) { + $collResourceDescs[] = $obj; + } + } + } + + $this->collResourceDescs = $collResourceDescs; + $this->collResourceDescsPartial = false; + } + } + + return $this->collResourceDescs; + } + + /** + * Sets a collection of ResourceDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $resourceDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setResourceDescs(PropelCollection $resourceDescs, PropelPDO $con = null) + { + $this->resourceDescsScheduledForDeletion = $this->getResourceDescs(new Criteria(), $con)->diff($resourceDescs); + + foreach ($this->resourceDescsScheduledForDeletion as $resourceDescRemoved) { + $resourceDescRemoved->setResource(null); + } + + $this->collResourceDescs = null; + foreach ($resourceDescs as $resourceDesc) { + $this->addResourceDesc($resourceDesc); + } + + $this->collResourceDescs = $resourceDescs; + $this->collResourceDescsPartial = false; + } + + /** + * Returns the number of related ResourceDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related ResourceDesc objects. + * @throws PropelException + */ + public function countResourceDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collResourceDescsPartial && !$this->isNew(); + if (null === $this->collResourceDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collResourceDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getResourceDescs()); + } + $query = ResourceDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByResource($this) + ->count($con); + } + } else { + return count($this->collResourceDescs); + } + } + + /** + * Method called to associate a ResourceDesc object to this object + * through the ResourceDesc foreign key attribute. + * + * @param ResourceDesc $l ResourceDesc + * @return Resource The current object (for fluent API support) + */ + public function addResourceDesc(ResourceDesc $l) + { + if ($this->collResourceDescs === null) { $this->initResourceDescs(); + $this->collResourceDescsPartial = true; + } + if (!$this->collResourceDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddResourceDesc($l); + } + + return $this; + } + + /** + * @param ResourceDesc $resourceDesc The resourceDesc object to add. + */ + protected function doAddResourceDesc($resourceDesc) + { + $this->collResourceDescs[]= $resourceDesc; + $resourceDesc->setResource($this); + } + + /** + * @param ResourceDesc $resourceDesc The resourceDesc object to remove. + */ + public function removeResourceDesc($resourceDesc) + { + if ($this->getResourceDescs()->contains($resourceDesc)) { + $this->collResourceDescs->remove($this->collResourceDescs->search($resourceDesc)); + if (null === $this->resourceDescsScheduledForDeletion) { + $this->resourceDescsScheduledForDeletion = clone $this->collResourceDescs; + $this->resourceDescsScheduledForDeletion->clear(); + } + $this->resourceDescsScheduledForDeletion[]= $resourceDesc; + $resourceDesc->setResource(null); } } @@ -1303,213 +1521,6 @@ abstract class BaseResource extends BaseObject implements Persistent return $this->getGroupResources($query, $con); } - /** - * Clears out the collResourceDescs collection - * - * 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 - * @see addResourceDescs() - */ - public function clearResourceDescs() - { - $this->collResourceDescs = null; // important to set this to null since that means it is uninitialized - $this->collResourceDescsPartial = null; - } - - /** - * reset is the collResourceDescs collection loaded partially - * - * @return void - */ - public function resetPartialResourceDescs($v = true) - { - $this->collResourceDescsPartial = $v; - } - - /** - * Initializes the collResourceDescs collection. - * - * By default this just sets the collResourceDescs collection to an empty array (like clearcollResourceDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initResourceDescs($overrideExisting = true) - { - if (null !== $this->collResourceDescs && !$overrideExisting) { - return; - } - $this->collResourceDescs = new PropelObjectCollection(); - $this->collResourceDescs->setModel('ResourceDesc'); - } - - /** - * Gets an array of ResourceDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Resource is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ResourceDesc[] List of ResourceDesc objects - * @throws PropelException - */ - public function getResourceDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collResourceDescsPartial && !$this->isNew(); - if (null === $this->collResourceDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collResourceDescs) { - // return empty collection - $this->initResourceDescs(); - } else { - $collResourceDescs = ResourceDescQuery::create(null, $criteria) - ->filterByResource($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collResourceDescsPartial && count($collResourceDescs)) { - $this->initResourceDescs(false); - - foreach($collResourceDescs as $obj) { - if (false == $this->collResourceDescs->contains($obj)) { - $this->collResourceDescs->append($obj); - } - } - - $this->collResourceDescsPartial = true; - } - - return $collResourceDescs; - } - - if($partial && $this->collResourceDescs) { - foreach($this->collResourceDescs as $obj) { - if($obj->isNew()) { - $collResourceDescs[] = $obj; - } - } - } - - $this->collResourceDescs = $collResourceDescs; - $this->collResourceDescsPartial = false; - } - } - - return $this->collResourceDescs; - } - - /** - * Sets a collection of ResourceDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $resourceDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setResourceDescs(PropelCollection $resourceDescs, PropelPDO $con = null) - { - $this->resourceDescsScheduledForDeletion = $this->getResourceDescs(new Criteria(), $con)->diff($resourceDescs); - - foreach ($this->resourceDescsScheduledForDeletion as $resourceDescRemoved) { - $resourceDescRemoved->setResource(null); - } - - $this->collResourceDescs = null; - foreach ($resourceDescs as $resourceDesc) { - $this->addResourceDesc($resourceDesc); - } - - $this->collResourceDescs = $resourceDescs; - $this->collResourceDescsPartial = false; - } - - /** - * Returns the number of related ResourceDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ResourceDesc objects. - * @throws PropelException - */ - public function countResourceDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collResourceDescsPartial && !$this->isNew(); - if (null === $this->collResourceDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collResourceDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getResourceDescs()); - } - $query = ResourceDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); - } - } else { - return count($this->collResourceDescs); - } - } - - /** - * Method called to associate a ResourceDesc object to this object - * through the ResourceDesc foreign key attribute. - * - * @param ResourceDesc $l ResourceDesc - * @return Resource The current object (for fluent API support) - */ - public function addResourceDesc(ResourceDesc $l) - { - if ($this->collResourceDescs === null) { - $this->initResourceDescs(); - $this->collResourceDescsPartial = true; - } - if (!$this->collResourceDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddResourceDesc($l); - } - - return $this; - } - - /** - * @param ResourceDesc $resourceDesc The resourceDesc object to add. - */ - protected function doAddResourceDesc($resourceDesc) - { - $this->collResourceDescs[]= $resourceDesc; - $resourceDesc->setResource($this); - } - - /** - * @param ResourceDesc $resourceDesc The resourceDesc object to remove. - */ - public function removeResourceDesc($resourceDesc) - { - if ($this->getResourceDescs()->contains($resourceDesc)) { - $this->collResourceDescs->remove($this->collResourceDescs->search($resourceDesc)); - if (null === $this->resourceDescsScheduledForDeletion) { - $this->resourceDescsScheduledForDeletion = clone $this->collResourceDescs; - $this->resourceDescsScheduledForDeletion->clear(); - } - $this->resourceDescsScheduledForDeletion[]= $resourceDesc; - $resourceDesc->setResource(null); - } - } - /** * Clears the current object and sets all attributes to their default values */ @@ -1539,26 +1550,26 @@ abstract class BaseResource extends BaseObject implements Persistent public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collGroupResources) { - foreach ($this->collGroupResources as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collResourceDescs) { foreach ($this->collResourceDescs as $o) { $o->clearAllReferences($deep); } } + if ($this->collGroupResources) { + foreach ($this->collGroupResources as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) - if ($this->collGroupResources instanceof PropelCollection) { - $this->collGroupResources->clearIterator(); - } - $this->collGroupResources = null; if ($this->collResourceDescs instanceof PropelCollection) { $this->collResourceDescs->clearIterator(); } $this->collResourceDescs = null; + if ($this->collGroupResources instanceof PropelCollection) { + $this->collGroupResources->clearIterator(); + } + $this->collGroupResources = null; } /** @@ -1581,4 +1592,18 @@ abstract class BaseResource extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Resource The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ResourcePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseResourceDesc.php b/core/lib/Thelia/Model/om/BaseResourceDesc.php index cb9f40450..93211676a 100644 --- a/core/lib/Thelia/Model/om/BaseResourceDesc.php +++ b/core/lib/Thelia/Model/om/BaseResourceDesc.php @@ -534,8 +534,19 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ResourceDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ResourceDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ResourceDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1207,4 +1218,18 @@ abstract class BaseResourceDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ResourceDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ResourceDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseResourceDescQuery.php b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php index 96116f0b5..8099a73a4 100644 --- a/core/lib/Thelia/Model/om/BaseResourceDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseResourceDescQuery.php @@ -544,4 +544,69 @@ abstract class BaseResourceDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ResourceDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ResourceDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ResourceDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ResourceDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ResourceDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ResourceDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ResourceDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseResourcePeer.php b/core/lib/Thelia/Model/om/BaseResourcePeer.php index 8e8b5754c..e8bfad535 100644 --- a/core/lib/Thelia/Model/om/BaseResourcePeer.php +++ b/core/lib/Thelia/Model/om/BaseResourcePeer.php @@ -379,12 +379,12 @@ abstract class BaseResourcePeer */ public static function clearRelatedInstancePool() { - // Invalidate objects in GroupResourcePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupResourcePeer::clearInstancePool(); // Invalidate objects in ResourceDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ResourceDescPeer::clearInstancePool(); + // Invalidate objects in GroupResourcePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + GroupResourcePeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/om/BaseResourceQuery.php index 9ae6f0863..575b22d48 100644 --- a/core/lib/Thelia/Model/om/BaseResourceQuery.php +++ b/core/lib/Thelia/Model/om/BaseResourceQuery.php @@ -37,14 +37,14 @@ use Thelia\Model\ResourceQuery; * @method ResourceQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ResourceQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ResourceQuery leftJoinGroupResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupResource relation - * @method ResourceQuery rightJoinGroupResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupResource relation - * @method ResourceQuery innerJoinGroupResource($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupResource relation - * * @method ResourceQuery leftJoinResourceDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ResourceDesc relation * @method ResourceQuery rightJoinResourceDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ResourceDesc relation * @method ResourceQuery innerJoinResourceDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the ResourceDesc relation * + * @method ResourceQuery leftJoinGroupResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupResource relation + * @method ResourceQuery rightJoinGroupResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupResource relation + * @method ResourceQuery innerJoinGroupResource($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupResource relation + * * @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 * @@ -377,80 +377,6 @@ abstract class BaseResourceQuery extends ModelCriteria return $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt, $comparison); } - /** - * Filter the query by a related GroupResource object - * - * @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. - */ - public function filterByGroupResource($groupResource, $comparison = null) - { - if ($groupResource instanceof GroupResource) { - return $this - ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison); - } elseif ($groupResource instanceof PropelObjectCollection) { - return $this - ->useGroupResourceQuery() - ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupResource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ResourceQuery The current query, for fluid interface - */ - public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupResource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupResource'); - } - - return $this; - } - - /** - * Use the GroupResource relation GroupResource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query - */ - public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); - } - /** * Filter the query by a related ResourceDesc object * @@ -525,6 +451,80 @@ abstract class BaseResourceQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ResourceDesc', '\Thelia\Model\ResourceDescQuery'); } + /** + * Filter the query by a related GroupResource object + * + * @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. + */ + public function filterByGroupResource($groupResource, $comparison = null) + { + if ($groupResource instanceof GroupResource) { + return $this + ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison); + } elseif ($groupResource instanceof PropelObjectCollection) { + return $this + ->useGroupResourceQuery() + ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the GroupResource relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ResourceQuery The current query, for fluid interface + */ + public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('GroupResource'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'GroupResource'); + } + + return $this; + } + + /** + * Use the GroupResource relation GroupResource object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query + */ + public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinGroupResource($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); + } + /** * Exclude object from result * @@ -541,4 +541,69 @@ abstract class BaseResourceQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ResourceQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ResourceQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ResourcePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ResourceQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ResourcePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ResourceQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return ResourceQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ResourcePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ResourceQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ResourcePeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/om/BaseRewriting.php index 87352cd3c..109a395db 100644 --- a/core/lib/Thelia/Model/om/BaseRewriting.php +++ b/core/lib/Thelia/Model/om/BaseRewriting.php @@ -655,8 +655,19 @@ abstract class BaseRewriting extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(RewritingPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(RewritingPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(RewritingPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1555,4 +1566,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Rewriting The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = RewritingPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/om/BaseRewritingQuery.php index e2e0c3066..d3e2b47c7 100644 --- a/core/lib/Thelia/Model/om/BaseRewritingQuery.php +++ b/core/lib/Thelia/Model/om/BaseRewritingQuery.php @@ -895,4 +895,69 @@ abstract class BaseRewritingQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return RewritingQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(RewritingPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return RewritingQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return RewritingQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return RewritingQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(RewritingPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return RewritingQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return RewritingQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseStock.php b/core/lib/Thelia/Model/om/BaseStock.php index 1eb1c7c68..70aeb15c5 100644 --- a/core/lib/Thelia/Model/om/BaseStock.php +++ b/core/lib/Thelia/Model/om/BaseStock.php @@ -587,8 +587,19 @@ abstract class BaseStock extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(StockPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(StockPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(StockPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1345,4 +1356,18 @@ abstract class BaseStock extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Stock The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = StockPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/om/BaseStockQuery.php index 916de2f0f..6cbbd1b1e 100644 --- a/core/lib/Thelia/Model/om/BaseStockQuery.php +++ b/core/lib/Thelia/Model/om/BaseStockQuery.php @@ -696,4 +696,69 @@ abstract class BaseStockQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return StockQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(StockPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return StockQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(StockPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return StockQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(StockPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return StockQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(StockPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return StockQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(StockPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return StockQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(StockPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseTax.php b/core/lib/Thelia/Model/om/BaseTax.php index 88132e987..f0cb83d1b 100644 --- a/core/lib/Thelia/Model/om/BaseTax.php +++ b/core/lib/Thelia/Model/om/BaseTax.php @@ -477,8 +477,19 @@ abstract class BaseTax extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1607,4 +1618,18 @@ abstract class BaseTax extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Tax The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseTaxDesc.php b/core/lib/Thelia/Model/om/BaseTaxDesc.php index babd76e97..ab5544556 100644 --- a/core/lib/Thelia/Model/om/BaseTaxDesc.php +++ b/core/lib/Thelia/Model/om/BaseTaxDesc.php @@ -572,8 +572,19 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1262,4 +1273,18 @@ abstract class BaseTaxDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return TaxDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseTaxDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php index f7c774672..b737bf264 100644 --- a/core/lib/Thelia/Model/om/BaseTaxDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxDescQuery.php @@ -577,4 +577,69 @@ abstract class BaseTaxDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TaxDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TaxDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TaxDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return TaxDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TaxDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/om/BaseTaxQuery.php index f28d71d01..c2853d9d9 100644 --- a/core/lib/Thelia/Model/om/BaseTaxQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxQuery.php @@ -553,4 +553,69 @@ abstract class BaseTaxQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return TaxQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TaxPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return TaxQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return TaxQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return TaxQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TaxPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return TaxQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TaxPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return TaxQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TaxPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/om/BaseTaxRule.php index 3652824ce..e6291bd07 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRule.php +++ b/core/lib/Thelia/Model/om/BaseTaxRule.php @@ -83,18 +83,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent protected $collProducts; protected $collProductsPartial; - /** - * @var PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects. - */ - protected $collTaxRuleCountrys; - protected $collTaxRuleCountrysPartial; - /** * @var PropelObjectCollection|TaxRuleDesc[] Collection to store aggregation of TaxRuleDesc objects. */ protected $collTaxRuleDescs; protected $collTaxRuleDescsPartial; + /** + * @var PropelObjectCollection|TaxRuleCountry[] Collection to store aggregation of TaxRuleCountry objects. + */ + protected $collTaxRuleCountrys; + protected $collTaxRuleCountrysPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -119,13 +119,13 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $taxRuleCountrysScheduledForDeletion = null; + protected $taxRuleDescsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var PropelObjectCollection */ - protected $taxRuleDescsScheduledForDeletion = null; + protected $taxRuleCountrysScheduledForDeletion = null; /** * Get the [id] column value. @@ -417,10 +417,10 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collProducts = null; - $this->collTaxRuleCountrys = null; - $this->collTaxRuleDescs = null; + $this->collTaxRuleCountrys = null; + } // if (deep) } @@ -493,8 +493,19 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxRulePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -563,24 +574,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - if ($this->taxRuleCountrysScheduledForDeletion !== null) { - if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) { - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) { - // need to save related object because we set the relation to null - $taxRuleCountry->save($con); - } - $this->taxRuleCountrysScheduledForDeletion = null; - } - } - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->taxRuleDescsScheduledForDeletion !== null) { if (!$this->taxRuleDescsScheduledForDeletion->isEmpty()) { foreach ($this->taxRuleDescsScheduledForDeletion as $taxRuleDesc) { @@ -599,6 +592,24 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } + if ($this->taxRuleCountrysScheduledForDeletion !== null) { + if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) { + foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) { + // need to save related object because we set the relation to null + $taxRuleCountry->save($con); + } + $this->taxRuleCountrysScheduledForDeletion = null; + } + } + + if ($this->collTaxRuleCountrys !== null) { + foreach ($this->collTaxRuleCountrys as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -767,16 +778,16 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { + if ($this->collTaxRuleDescs !== null) { + foreach ($this->collTaxRuleDescs as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } } } - if ($this->collTaxRuleDescs !== null) { - foreach ($this->collTaxRuleDescs as $referrerFK) { + if ($this->collTaxRuleCountrys !== null) { + foreach ($this->collTaxRuleCountrys as $referrerFK) { if (!$referrerFK->validate($columns)) { $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); } @@ -868,12 +879,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null !== $this->collProducts) { $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collTaxRuleCountrys) { - $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collTaxRuleDescs) { $result['TaxRuleDescs'] = $this->collTaxRuleDescs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collTaxRuleCountrys) { + $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1043,18 +1054,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - foreach ($this->getTaxRuleCountrys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); - } - } - foreach ($this->getTaxRuleDescs() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addTaxRuleDesc($relObj->copy($deepCopy)); } } + foreach ($this->getTaxRuleCountrys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); + } + } + //unflag object copy $this->startCopy = false; } // if ($deepCopy) @@ -1119,12 +1130,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ('Product' == $relationName) { $this->initProducts(); } - if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); - } if ('TaxRuleDesc' == $relationName) { $this->initTaxRuleDescs(); } + if ('TaxRuleCountry' == $relationName) { + $this->initTaxRuleCountrys(); + } } /** @@ -1334,6 +1345,213 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } + /** + * Clears out the collTaxRuleDescs collection + * + * 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 + * @see addTaxRuleDescs() + */ + public function clearTaxRuleDescs() + { + $this->collTaxRuleDescs = null; // important to set this to null since that means it is uninitialized + $this->collTaxRuleDescsPartial = null; + } + + /** + * reset is the collTaxRuleDescs collection loaded partially + * + * @return void + */ + public function resetPartialTaxRuleDescs($v = true) + { + $this->collTaxRuleDescsPartial = $v; + } + + /** + * Initializes the collTaxRuleDescs collection. + * + * By default this just sets the collTaxRuleDescs collection to an empty array (like clearcollTaxRuleDescs()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initTaxRuleDescs($overrideExisting = true) + { + if (null !== $this->collTaxRuleDescs && !$overrideExisting) { + return; + } + $this->collTaxRuleDescs = new PropelObjectCollection(); + $this->collTaxRuleDescs->setModel('TaxRuleDesc'); + } + + /** + * Gets an array of TaxRuleDesc objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this TaxRule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param PropelPDO $con optional connection object + * @return PropelObjectCollection|TaxRuleDesc[] List of TaxRuleDesc objects + * @throws PropelException + */ + public function getTaxRuleDescs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collTaxRuleDescsPartial && !$this->isNew(); + if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleDescs) { + // return empty collection + $this->initTaxRuleDescs(); + } else { + $collTaxRuleDescs = TaxRuleDescQuery::create(null, $criteria) + ->filterByTaxRule($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collTaxRuleDescsPartial && count($collTaxRuleDescs)) { + $this->initTaxRuleDescs(false); + + foreach($collTaxRuleDescs as $obj) { + if (false == $this->collTaxRuleDescs->contains($obj)) { + $this->collTaxRuleDescs->append($obj); + } + } + + $this->collTaxRuleDescsPartial = true; + } + + return $collTaxRuleDescs; + } + + if($partial && $this->collTaxRuleDescs) { + foreach($this->collTaxRuleDescs as $obj) { + if($obj->isNew()) { + $collTaxRuleDescs[] = $obj; + } + } + } + + $this->collTaxRuleDescs = $collTaxRuleDescs; + $this->collTaxRuleDescsPartial = false; + } + } + + return $this->collTaxRuleDescs; + } + + /** + * Sets a collection of TaxRuleDesc objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $taxRuleDescs A Propel collection. + * @param PropelPDO $con Optional connection object + */ + public function setTaxRuleDescs(PropelCollection $taxRuleDescs, PropelPDO $con = null) + { + $this->taxRuleDescsScheduledForDeletion = $this->getTaxRuleDescs(new Criteria(), $con)->diff($taxRuleDescs); + + foreach ($this->taxRuleDescsScheduledForDeletion as $taxRuleDescRemoved) { + $taxRuleDescRemoved->setTaxRule(null); + } + + $this->collTaxRuleDescs = null; + foreach ($taxRuleDescs as $taxRuleDesc) { + $this->addTaxRuleDesc($taxRuleDesc); + } + + $this->collTaxRuleDescs = $taxRuleDescs; + $this->collTaxRuleDescsPartial = false; + } + + /** + * Returns the number of related TaxRuleDesc objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related TaxRuleDesc objects. + * @throws PropelException + */ + public function countTaxRuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collTaxRuleDescsPartial && !$this->isNew(); + if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleDescs) { + return 0; + } else { + if($partial && !$criteria) { + return count($this->getTaxRuleDescs()); + } + $query = TaxRuleDescQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTaxRule($this) + ->count($con); + } + } else { + return count($this->collTaxRuleDescs); + } + } + + /** + * Method called to associate a TaxRuleDesc object to this object + * through the TaxRuleDesc foreign key attribute. + * + * @param TaxRuleDesc $l TaxRuleDesc + * @return TaxRule The current object (for fluent API support) + */ + public function addTaxRuleDesc(TaxRuleDesc $l) + { + if ($this->collTaxRuleDescs === null) { + $this->initTaxRuleDescs(); + $this->collTaxRuleDescsPartial = true; + } + if (!$this->collTaxRuleDescs->contains($l)) { // only add it if the **same** object is not already associated + $this->doAddTaxRuleDesc($l); + } + + return $this; + } + + /** + * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to add. + */ + protected function doAddTaxRuleDesc($taxRuleDesc) + { + $this->collTaxRuleDescs[]= $taxRuleDesc; + $taxRuleDesc->setTaxRule($this); + } + + /** + * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to remove. + */ + public function removeTaxRuleDesc($taxRuleDesc) + { + if ($this->getTaxRuleDescs()->contains($taxRuleDesc)) { + $this->collTaxRuleDescs->remove($this->collTaxRuleDescs->search($taxRuleDesc)); + if (null === $this->taxRuleDescsScheduledForDeletion) { + $this->taxRuleDescsScheduledForDeletion = clone $this->collTaxRuleDescs; + $this->taxRuleDescsScheduledForDeletion->clear(); + } + $this->taxRuleDescsScheduledForDeletion[]= $taxRuleDesc; + $taxRuleDesc->setTaxRule(null); + } + } + /** * Clears out the collTaxRuleCountrys collection * @@ -1591,213 +1809,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent return $this->getTaxRuleCountrys($query, $con); } - /** - * Clears out the collTaxRuleDescs collection - * - * 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 - * @see addTaxRuleDescs() - */ - public function clearTaxRuleDescs() - { - $this->collTaxRuleDescs = null; // important to set this to null since that means it is uninitialized - $this->collTaxRuleDescsPartial = null; - } - - /** - * reset is the collTaxRuleDescs collection loaded partially - * - * @return void - */ - public function resetPartialTaxRuleDescs($v = true) - { - $this->collTaxRuleDescsPartial = $v; - } - - /** - * Initializes the collTaxRuleDescs collection. - * - * By default this just sets the collTaxRuleDescs collection to an empty array (like clearcollTaxRuleDescs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initTaxRuleDescs($overrideExisting = true) - { - if (null !== $this->collTaxRuleDescs && !$overrideExisting) { - return; - } - $this->collTaxRuleDescs = new PropelObjectCollection(); - $this->collTaxRuleDescs->setModel('TaxRuleDesc'); - } - - /** - * Gets an array of TaxRuleDesc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this TaxRule is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxRuleDesc[] List of TaxRuleDesc objects - * @throws PropelException - */ - public function getTaxRuleDescs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxRuleDescsPartial && !$this->isNew(); - if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleDescs) { - // return empty collection - $this->initTaxRuleDescs(); - } else { - $collTaxRuleDescs = TaxRuleDescQuery::create(null, $criteria) - ->filterByTaxRule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxRuleDescsPartial && count($collTaxRuleDescs)) { - $this->initTaxRuleDescs(false); - - foreach($collTaxRuleDescs as $obj) { - if (false == $this->collTaxRuleDescs->contains($obj)) { - $this->collTaxRuleDescs->append($obj); - } - } - - $this->collTaxRuleDescsPartial = true; - } - - return $collTaxRuleDescs; - } - - if($partial && $this->collTaxRuleDescs) { - foreach($this->collTaxRuleDescs as $obj) { - if($obj->isNew()) { - $collTaxRuleDescs[] = $obj; - } - } - } - - $this->collTaxRuleDescs = $collTaxRuleDescs; - $this->collTaxRuleDescsPartial = false; - } - } - - return $this->collTaxRuleDescs; - } - - /** - * Sets a collection of TaxRuleDesc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $taxRuleDescs A Propel collection. - * @param PropelPDO $con Optional connection object - */ - public function setTaxRuleDescs(PropelCollection $taxRuleDescs, PropelPDO $con = null) - { - $this->taxRuleDescsScheduledForDeletion = $this->getTaxRuleDescs(new Criteria(), $con)->diff($taxRuleDescs); - - foreach ($this->taxRuleDescsScheduledForDeletion as $taxRuleDescRemoved) { - $taxRuleDescRemoved->setTaxRule(null); - } - - $this->collTaxRuleDescs = null; - foreach ($taxRuleDescs as $taxRuleDesc) { - $this->addTaxRuleDesc($taxRuleDesc); - } - - $this->collTaxRuleDescs = $taxRuleDescs; - $this->collTaxRuleDescsPartial = false; - } - - /** - * Returns the number of related TaxRuleDesc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxRuleDesc objects. - * @throws PropelException - */ - public function countTaxRuleDescs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxRuleDescsPartial && !$this->isNew(); - if (null === $this->collTaxRuleDescs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleDescs) { - return 0; - } else { - if($partial && !$criteria) { - return count($this->getTaxRuleDescs()); - } - $query = TaxRuleDescQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); - } - } else { - return count($this->collTaxRuleDescs); - } - } - - /** - * Method called to associate a TaxRuleDesc object to this object - * through the TaxRuleDesc foreign key attribute. - * - * @param TaxRuleDesc $l TaxRuleDesc - * @return TaxRule The current object (for fluent API support) - */ - public function addTaxRuleDesc(TaxRuleDesc $l) - { - if ($this->collTaxRuleDescs === null) { - $this->initTaxRuleDescs(); - $this->collTaxRuleDescsPartial = true; - } - if (!$this->collTaxRuleDescs->contains($l)) { // only add it if the **same** object is not already associated - $this->doAddTaxRuleDesc($l); - } - - return $this; - } - - /** - * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to add. - */ - protected function doAddTaxRuleDesc($taxRuleDesc) - { - $this->collTaxRuleDescs[]= $taxRuleDesc; - $taxRuleDesc->setTaxRule($this); - } - - /** - * @param TaxRuleDesc $taxRuleDesc The taxRuleDesc object to remove. - */ - public function removeTaxRuleDesc($taxRuleDesc) - { - if ($this->getTaxRuleDescs()->contains($taxRuleDesc)) { - $this->collTaxRuleDescs->remove($this->collTaxRuleDescs->search($taxRuleDesc)); - if (null === $this->taxRuleDescsScheduledForDeletion) { - $this->taxRuleDescsScheduledForDeletion = clone $this->collTaxRuleDescs; - $this->taxRuleDescsScheduledForDeletion->clear(); - } - $this->taxRuleDescsScheduledForDeletion[]= $taxRuleDesc; - $taxRuleDesc->setTaxRule(null); - } - } - /** * Clears the current object and sets all attributes to their default values */ @@ -1832,13 +1843,13 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collTaxRuleCountrys) { - foreach ($this->collTaxRuleCountrys as $o) { + if ($this->collTaxRuleDescs) { + foreach ($this->collTaxRuleDescs as $o) { $o->clearAllReferences($deep); } } - if ($this->collTaxRuleDescs) { - foreach ($this->collTaxRuleDescs as $o) { + if ($this->collTaxRuleCountrys) { + foreach ($this->collTaxRuleCountrys as $o) { $o->clearAllReferences($deep); } } @@ -1848,14 +1859,14 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->collProducts->clearIterator(); } $this->collProducts = null; - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); - } - $this->collTaxRuleCountrys = null; if ($this->collTaxRuleDescs instanceof PropelCollection) { $this->collTaxRuleDescs->clearIterator(); } $this->collTaxRuleDescs = null; + if ($this->collTaxRuleCountrys instanceof PropelCollection) { + $this->collTaxRuleCountrys->clearIterator(); + } + $this->collTaxRuleCountrys = null; } /** @@ -1878,4 +1889,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return TaxRule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php index a510c4ba2..af89f156c 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php @@ -602,8 +602,19 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1417,4 +1428,18 @@ abstract class BaseTaxRuleCountry extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return TaxRuleCountry The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxRuleCountryPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php index 37af55fe7..cb0dad946 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php @@ -779,4 +779,69 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleCountryPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleCountryPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return TaxRuleCountryQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php index fde9bb97b..d5debaafb 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleDesc.php @@ -572,8 +572,19 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent $ret = $this->preSave($con); if ($isInsert) { $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxRuleDescPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxRuleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } else { $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxRuleDescPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } } if ($ret) { $affectedRows = $this->doSave($con); @@ -1262,4 +1273,18 @@ abstract class BaseTaxRuleDesc extends BaseObject implements Persistent return $this->alreadyInSave; } + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return TaxRuleDesc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxRuleDescPeer::UPDATED_AT; + + return $this; + } + } diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php index 98f7d5d13..2e0f8d413 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleDescQuery.php @@ -577,4 +577,69 @@ abstract class BaseTaxRuleDescQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TaxRuleDescPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleDescPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleDescPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TaxRuleDescPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleDescPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return TaxRuleDescQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleDescPeer::CREATED_AT); + } } diff --git a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php index 1b038414b..31117ed29 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php +++ b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php @@ -383,12 +383,12 @@ abstract class BaseTaxRulePeer // Invalidate objects in ProductPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductPeer::clearInstancePool(); - // Invalidate objects in TaxRuleCountryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxRuleCountryPeer::clearInstancePool(); // Invalidate objects in TaxRuleDescPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TaxRuleDescPeer::clearInstancePool(); + // Invalidate objects in TaxRuleCountryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + TaxRuleCountryPeer::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php index 0a96357bf..53945ee71 100644 --- a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php +++ b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php @@ -42,14 +42,14 @@ use Thelia\Model\TaxRuleQuery; * @method TaxRuleQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation * @method TaxRuleQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation * - * @method TaxRuleQuery leftJoinTaxRuleCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRuleCountry relation - * @method TaxRuleQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation - * @method TaxRuleQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation - * * @method TaxRuleQuery leftJoinTaxRuleDesc($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRuleDesc relation * @method TaxRuleQuery rightJoinTaxRuleDesc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleDesc relation * @method TaxRuleQuery innerJoinTaxRuleDesc($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleDesc relation * + * @method TaxRuleQuery leftJoinTaxRuleCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaxRuleCountry relation + * @method TaxRuleQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation + * @method TaxRuleQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation + * * @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 * @@ -456,80 +456,6 @@ abstract class BaseTaxRuleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); } - /** - * Filter the query by a related TaxRuleCountry object - * - * @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. - */ - public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) - { - if ($taxRuleCountry instanceof TaxRuleCountry) { - return $this - ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { - return $this - ->useTaxRuleCountryQuery() - ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRuleCountry relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRuleCountry'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRuleCountry'); - } - - return $this; - } - - /** - * Use the TaxRuleCountry relation TaxRuleCountry object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRuleCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); - } - /** * Filter the query by a related TaxRuleDesc object * @@ -604,6 +530,80 @@ abstract class BaseTaxRuleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'TaxRuleDesc', '\Thelia\Model\TaxRuleDescQuery'); } + /** + * Filter the query by a related TaxRuleCountry object + * + * @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. + */ + public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) + { + if ($taxRuleCountry instanceof TaxRuleCountry) { + return $this + ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison); + } elseif ($taxRuleCountry instanceof PropelObjectCollection) { + return $this + ->useTaxRuleCountryQuery() + ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the TaxRuleCountry relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('TaxRuleCountry'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'TaxRuleCountry'); + } + + return $this; + } + + /** + * Use the TaxRuleCountry relation TaxRuleCountry object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query + */ + public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinTaxRuleCountry($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); + } + /** * Exclude object from result * @@ -620,4 +620,69 @@ abstract class BaseTaxRuleQuery extends ModelCriteria return $this; } + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRulePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRulePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(TaxRulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRulePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return TaxRuleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRulePeer::CREATED_AT); + } } diff --git a/local/config/schema.xml b/local/config/schema.xml index 51bbbd716..d98538cb1 100644 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1153 +1,1088 @@ - - - - - - - - - - - - + + +
+ + + + + + +
+ + + + + + + + + + - - - - - - - - + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - -
- - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + - - - - - -
- - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - + - + +
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - +
+ + + + + + + + + - + +
- - - - - - - - +
+ + + + + + + + + + + + + + +
- - - - - - - - - +
+ + + + + + + - - + + +
- - - - - - - - - - - +
+ + + + + + + + - - - - - - - - - - - - - - - - - - - - + + +
- - - - - - - - - - - - - - - - - - - - +
+ + +
- - - - - -
- - - - - - - - - - +
+ + + + + + + - + +
- - - - - +
+ + +
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - +
+ + + + + + + - + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + +